Showing posts with label components. Show all posts
Showing posts with label components. Show all posts

Saturday, December 30, 2017

iLogic Virtual Components

iLogic Virtual Components





Issue:
You have some iLogic code that iterates through all of the components in an assembly and does some something with the file for each. However, if the assembly contains a virtual component then the iLogic code fails. Is there a way to skip over virtual components when encountered?

Solution:
Here is an iLogic snippet that demonstrates this using If Not TypeOf. In this simple example the iLogic rule simply displays the occurrence name if the occurrence is not a virtual component.


------------ start of ilogic--------------------
set a reference to the assembly component definintion.
This assumes an assembly document is open.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
check for and skip virtual components
(in case a virtual component trips things up)
If Not TypeOf oOccurrence.Definition Is VirtualComponentDefinition Then
Show occurrence name In the message box body
MessageBox.Show(oOccurrence.Name, "iLogic")
Else
End If
Next
------------ end of ilogic--------------------


visit link download
Read more »

Tuesday, December 26, 2017

iLogic Suppress Components in all but the Active Level of Detail

iLogic Suppress Components in all but the Active Level of Detail


Issue:
Your assembly has several Level of Detail Representations set up, which works well. The problem is that when you add a new component to the assembly, you have to go to each Level of Detail and suppress the component in order to prevent it from showing up in those existing Level of Detail Representations.



Solution:
Here is an iLogic rule that will suppress any selected components in all of the other LODs, with the exception of the active LOD.

This allows you to place the component in the assembly with the LOD you want to add the component to set active, then select the component (or components) and run this iLogic rule to remove the component(s) from the other LODs.

This iLogic rule also doesnt suppress the selected components in the standard LODs, such as the "Master" LOD, the "All Content Center Suppressed" LOD, etc.

Note too that it saves the file each time one of the other LODs is modified in order to make the changes "stick", so if you have a large assembly with many LODs it might take a bit for this rule to run.






Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument

Find all selected components and add them to an ObjectCollection.
Dim oSelected As ObjectCollection
oSelected = ThisApplication.TransientObjects. _
CreateObjectCollection (oDoc.SelectSet)

define LOD rep
Dim oLODRep As LevelOfDetailRepresentation

define rep manager
Rep_Manager =ThisApplication.ActiveDocument. _
ComponentDefinition.RepresentationsManager

define an arraylist to hold the list of  LOD rep names
Dim NameList As New ArrayList()

look at the LOD reps in the assembly
For Each oLODRep in Rep_Manager.LevelOfDetailRepresentations
add the LOD names to the array list
NameList.add(oLODRep.Name)
Next

Dim myLOD as LevelOfDetailRepresentation
link download
Read more »