Showing posts with label virtual. Show all posts
Showing posts with label virtual. 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--------------------
Labels:
components,
ilogic,
virtual
Thursday, December 21, 2017
Ilogic Add Standard Virtual Parts From a Text File
Ilogic Add Standard Virtual Parts From a Text File
Issue:
You have a number of standard Virtual parts that you find yourself adding over and over. Youd like to have the ability to add them based on a predefined list.

Solution:
Here is an example iLogic rule that will read a *.txt file and present the contents to the user in an input box list. The user is then asked to enter a quantity for the virtual part, and then the virtual part occurrences are added to the assembly. If one or more occurrences of the virtual part exist in the assembly, the iLogic rule deletes them and just adds back the total number needed.
(update: see also iLogic - Add Standard Virtual Parts From an Excel File or a similar solution)
(update: see also iLogic - Add Standard Virtual Parts From an Excel File or a similar solution)
![]() |
| An example text file list |
![]() |
| The list presented to the user in an input list box. |
![]() |
| The input box presented to the user to set the quantity. |
![]() |
| The virtual parts added to the assembly. |
![]() |
| Adjusting the quantity. |
![]() |
| The iLogic rule deletes the original 18 occurrences and just adds back the number specified. |
Here is the example iLogic rule:
(special thanks to Brian Ekins for the code he posted at this link.)
(special thanks to Brian Ekins for the code he posted at this link.)
Dim MyArrayList As New ArrayList
MyArrayList = GoExcel.CellValues("U:iLogic examplesVirtual Part List.xls", "Sheet1", "A2", "A1000")
Dim sVirtPart As String
get user input from list
sVirtPart = InputListBox("Select a virtual part to add.", _
MyArrayList, MyArrayList.Item(0), "iLogic", "Standard Virtual Parts")
check for empty input in the case where the user cancels out of the input box
If sVirtPart = "" Then
Return end rule
Else
End if
get iProperties from the XLS file
For MyRow = 2 To 1000 index row 2 through 1000
find the cell in column A that matches the user selection
If sVirtPart = (GoExcel.CellValue("A" & MyRow)) Then
get the iProperty from the XLS file for each column
oProp1 = GoExcel.CellValue("A" & MyRow )
oProp2 = GoExcel.CellValue("B" & MyRow )
oProp3 = GoExcel.CellValue("C" & MyRow)
oProp4 = GoExcel.CellValue("D" & MyRow)
oProp5 = GoExcel.CellValue("E" & MyRow)
Exit For
End If
Next
get quantity from user
iQTY = InputBox("Enter the TOTAL number of:" _
& vblf & " " & sVirtPart & "" _
link download
Read more »
Subscribe to:
Posts (Atom)





