Files
Post-rebuild event notification example
Code
Module: mMain
'Demonstrates how to listen for post-rebuild notification in any document type.
'Precondition: document is open
'Result: message box is displayed after rebuild
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
Dim listener As New RebuildListener
Sub main()
listener.connect
End Sub
Class: RebuildListener
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim WithEvents swPart As SldWorks.PartDoc
Dim WithEvents swAssy As SldWorks.AssemblyDoc
Dim WithEvents swDraw As SldWorks.DrawingDoc
Public Sub connect()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then End
If swModel.GetType = swDocPART Then Set swPart = swModel
If swModel.GetType = swDocASSEMBLY Then Set swAssy = swModel
If swModel.GetType = swDocDRAWING Then Set swDraw = swModel
End Sub
Private Function swPart_RegenPostNotify2(ByVal stopFeature As Object) As Long
swApp.SendMsgToUser "Rebuild finished"
End Function
Private Function swAssy_RegenPostNotify2(ByVal stopFeature As Object) As Long
swApp.SendMsgToUser "Rebuild finished"
End Function
Private Function swDraw_RegenPostNotify() As Long
swApp.SendMsgToUser "Rebuild finished"
End Function