iLogic : modify all the components of an assembly

iLogic : modify all the components of an assembly

TONELLAL
Collaborator Collaborator
1,651 Views
3 Replies
Message 1 of 4

iLogic : modify all the components of an assembly

TONELLAL
Collaborator
Collaborator

Hello,

I need to modify all the ipt in an assembly, but I don't kow how many ipt I have, and I don't know the name. Can I have with iLogic the list of all the ipt used in the assembly ? For example, to modify the Part Number in all the components.

The code should be like this :

 

For All component in Assembly

...

...

Next component

0 Likes
1,652 Views
3 Replies
Replies (3)
Message 2 of 4

Curtis_Waguespack
Consultant
Consultant

Hi TONELLAL, 

 

This example will set the part number iProperty in all of the components in the assembly, to match the component name with a prefix:

 

' 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

'find colon SeparatorPosistion
Dim SeparatorPos As Long
SeparatorPos = InStrRev(oOccurrence.Name, ":",-1)

'define part number prefix   
Dim sPrefix As String
sPrefix = "Test_"
'set part number for each component
iProperties.Value(oOccurrence.Name, "Project", "Part Number") = sPrefix & Left(oOccurrence.Name,SeparatorPos -1)
Else
End If
Next

 

 

To present the list of all the components to the user, so one of them can be selected, you can use something like this:

 

 

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

Dim MyArrayList As New ArrayList

'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
MyArrayList.add(oOccurrence.Name)
Else
End If
Next

oSelected = InputListBox("Select a component to use", MyArrayList, MyArrayList.Item(0), "iLogic", "Component List")

MessageBox.Show("You selected: "  & vblf & oSelected, "iLogic")

 I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

Message 3 of 4

TONELLAL
Collaborator
Collaborator

Hi Curtis,

Thanks for your help ! The real rule I need is more complex, but your code help a lot. I was not very far from the solution, so I have another question : where do you find the syntax and method/properties specific to iLogic ? This is close to VBA but with differences : for example "Thisdoc" instead of "Thisdocument", doc.filename exist in iLogic but not in VBA,... In fact what is missing is the object model, perhaps you found it ?

 

Alain

0 Likes
Message 4 of 4

xiaodong_liang
Autodesk Support
Autodesk Support

Hi,

 

I do not find the object model for iLogic.The wiki help tells how to work with iLogic, including the relevant objects, e.g. Rules and Forms.

 

Yes, iLogic encapsulates some objects with the relevant functionalities which looks not exact like what you are using in VBA or .NET. But Basically, iLogic uses the same object model as what you can see in VBA or .NET. So the object browser of them may be of help for you. .Net browser is nicer than VBA, I think.

 

 

0 Likes