AnsweredAssumed Answered

Help with Macro to rebuild after running.

Question asked by Jason Corl on Mar 9, 2018
Latest reply on Mar 9, 2018 by Jason Corl

I've written the following macro to replace the standard "add revision symbol" button. SW currently will not allow you to save a default layer for Revision Symbols, yes for tables, clouds, dimensions etc, but not revision symbols. So this macro sets the layer and starts the revision symbol command then resets the active layer to "per-standard". Thus this macro has to have a layer named "rev" to run (no error handling on this).


We also have changed the revision symbol from triangle to box so I added the code to change the default in the document before placing the symbol.


The issue I'm having is the screen will not refresh/rebuild leaving a final rev symbol artifact up near the PropertyManager where I select the check mark to complete the operation. It disappears on a Control + Q.


When I added the rebuild code it simply exited out of the command before I could place symbols. Seems like I need add an event handler to detect when the check mark is selected or completed by RMB but I don't have experience doing this. I've done some reading and saw where you can use a non-modal dialog box to pause but thinking that will get clunky. Any ideas how to do it cleanly?


Sub RevSymbols_OnRevLayer()



Dim swApp As SldWorks.SldWorks

Dim swDwg As SldWorks.ModelDoc2

Dim sLayer As Boolean



Set swApp = Application.SldWorks

Set swDwg = swApp.ActiveDoc



If swDwg.GetType = swDocDRAWING Then



    swDwg.Extension.SetUserPreferenceInteger _

        swUserPreferenceIntegerValue_e.swRevisionTableSymbolShape, _

        swUserPreferenceOption_e.swDetailingNoOptionSpecified, _



    sLayer = swDwg.SetCurrentLayer("REV")


        swDwg.Extension.RunCommand SwCommands.swCommands_RevisionSymbol, ""




    sLayer = swDwg.SetCurrentLayer("-Per Standard-")


    'bRet = swDwg.ForceRebuild3(False)




    MsgBox ("Please open a drawing to use this feature.")


End If



End Sub