Friday 16 June 2017

Turn Routes On/Off

                It has finally caught up with me and I had to stop and write a code to turn Routes On/Off.

                Nothing fancy here but I found myself doing this so many times on this last project that I decided to make an iLogic external rule for it.

                This is very simple; just a few lines to check if the occurrence name starts with "Route" then turn the part off.

Dim oAssyDoc As AssemblyDocument
oAssyDoc = ThisApplication.ActiveDocument

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = oAssyDoc.ComponentDefinition

Dim oLeafOccs as ComponentOccurrencesEnumerator
oLeafOccs = oAsmCompDef.Occurrences.AllLeafOccurrences

Dim oOcc as ComponentOccurrence

'get user input as True or False
wfBoolean = InputRadioBox("Turn Routes On/Off", "On", "Off", False, "iLogic")

' Process the rule, wrapping it in a transaction so the
' entire process can be undone with a single undo operation.
Dim trans As Transaction
trans = ThisApplication.TransactionManager.StartTransaction( _
        oAssyDoc, "Routes On/Off")

    For Each oOcc In oLeafOccs
        If String.Compare(Left(oOcc.Name,5),"Route",False) = 0 Then
            oOcc.Visible = wfBoolean
        Else If String.Compare(Left(oOcc.Name,4),"Hose",False) = 0 Then
            oOcc.Visible = wfBoolean
        End If
'end transaction for single undo

'upate the files



No comments:

Post a Comment