This website uses cookies to ensure you get the best experience on our website. By using our website you agree on the following Cookie Policy, Privacy Policy, and Terms Of Use
When macro started form is displayed. While form is open all rebuild operations (regenerations) will be suspended.
For example dimension changes or mates will not resolve until Exit Suspend Rebuild Mode button is clicked.
Sub main()
FreezeRebuildForm.Show vbModeless
EndSub
User Form
Const CANCEL_REGEN AsLong = 1
Dim swApp As SldWorks.SldWorks
DimWithEvents swPart As SldWorks.PartDoc
DimWithEvents swAssy As SldWorks.AssemblyDoc
DimWithEvents swDraw As SldWorks.DrawingDoc
PrivateSub btnExit_Click()
EndEndSubPrivateSub UserForm_Initialize()
Set swApp = Application.SldWorks
Dim swModel As SldWorks.ModelDoc2
Set swModel = swApp.ActiveDoc
IfNot swModel IsNothingThenSelectCase swModel.GetType()
Case swDocumentTypes_e.swDocPART
Set swPart = swModel
Case swDocumentTypes_e.swDocASSEMBLY
Set swAssy = swModel
Case swDocumentTypes_e.swDocDRAWING
Set swDraw = swModel
EndSelectElse
MsgBox "Please open the model"EndEndIfEndSubPrivateFunction swAssy_RegenNotify() AsLong
swAssy_RegenNotify = CANCEL_REGEN
EndFunctionPrivateFunction swDraw_RegenNotify() AsLong
swDraw_RegenNotify = CANCEL_REGEN
EndFunctionPrivateFunction swPart_RegenNotify() AsLong
swPart_RegenNotify = CANCEL_REGEN
EndFunction
Notifications
Join session by SOLIDWORKS and PDM API expert Artem Taturevych at 3DEXPERIENCE World 2026 on Wednesday, Feb 4 at 08:30 AM CST to explore 10 essential macros for automating drawings, assemblies, custom properties, and more