Wednesday, August 15, 2012

iLogic: Virtual Components

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?

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")
End If
'------------ end of ilogic--------------------

Wednesday, August 1, 2012

Disable Automatic PDF Display

When you use Save As > Save Copy As > PDF, or Export > PDF,  Inventor always opens the PDF viewer to show the PDF file after it is published. This can be a bother, due to the delay caused by waiting for the PDF viewer to open each time. Is there a way to change this so that the PDF does not automatically open after it is published?

As odd as it sounds, this is controlled in the publish options of the DWF file. 

Go to Export > Export to DWF and un-check the Display Published File in Viewer option found at the bottom of the General tab. This option controls the PDF viewer as well as the DWF. With this option unchecked the PDF will not open automatically after it is published.