000

iLogic Solid Body Visibility

.


Issue:
You want to be able to control the visibility of Solid Bodies in a Multi Body part file using  your iLogic rule.




Solution:
Here is a quick example that demonstrates several options to toggle the visibility of solid bodies on and off.




'define the document as a component definition
Dim oCompDef as ComponentDefinition
oCompDef = ThisDoc.Document.ComponentDefinition

'define the solidbody
Dim oBody as SurfaceBody

'add each solid body name to a list
Dim MyArrayList As New ArrayList
i = 1
For Each SurfaceBody in oCompDef.SurfaceBodies
oBody = oCompDef.SurfaceBodies.Item(i)
MyArrayList.add(oBody.Name)
i = i +1
Next

'add Show and Hide all options to the list
MyArrayList.add(" *Show All")
MyArrayList.add(" *Hide All")

'present the user with the list and record the selection
sBody  = InputListBox("Select a Solid Body to Toggle Visibility.", _
MyArrayList, "", "iLogic", "List of Solid Bodies")

'toggle all on or all off, if those options were selected
If sBody = " *Show All" Then
          i = 1
          For Each SurfaceBody in oCompDef.SurfaceBodies
            oBody = oCompDef.SurfaceBodies.Item(i)
          oBody.Visible = True
            i = i +1
          Next
ElseIf sBody = " *Hide All"
            i = 1
          For Each SurfaceBody in oCompDef.SurfaceBodies
            oBody = oCompDef.SurfaceBodies.Item(i)
          oBody.Visible = False
            i = i +1
          Next
End If

'compare the user selection to the solid body names
'and toggle the visibility for the one the matches (if any)
i = 1
For Each SurfaceBody in oCompDef.SurfaceBodies
oBody = oCompDef.SurfaceBodies.Item(i)
If sBody = oBody.Name Then
          If oBody.Visible = False Then
          oBody.Visible = True
            Else
          oBody.Visible = False
            End If
End If
MyArrayList.add(oBody.Name)
i = i +1
Next

Blog Archive