Community
Can someone provide a macro that will allow me to, after selecting a part or component, toggle whether it is enabled or disabled. I would like this so that I can assign a keyboard shortcut to the macro, and then quickly enable/disable parts in an assembly.
Thank you for your help.
Solved! Go to Solution.
Solved by YuhanZhang. Go to Solution.
Here is the macro:
Sub ToggleOccuEnabled() Dim oDoc As Document Set oDoc = ThisApplication.ActiveDocument If oDoc.DocumentType = kAssemblyDocumentObject Then Dim oAssy As AssemblyDocument Set oAssy = oDoc Dim oDef As AssemblyComponentDefinition Set oDef = oAssy.ComponentDefinition If oAssy.SelectSet.Count <> 0 Then Dim oObj As Object Set oObj = oAssy.SelectSet(1) If TypeName(oObj) = "ComponentOccurrence" Then Dim oOccu As ComponentOccurrence Set oOccu = oObj ' Toggle the Enabled oOccu.Enabled = Not (oOccu.Enabled) End If End If End If End End Sub
I copied the macro provided into my vba module, and then set a keyboard shortcut for the ToggleOccuEnabled macro. It works like a charm. Thank you.