Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
tegstette
292 Views, 1 Reply

ilogic repalce part

Hi

 

I want to use illogic to find and replace compontents in an assembly by searching for specific properties in the parts (BOM) and replace these specific parts with another file.

 

Ex: If an assembly contains a part with Title: “Bracket 1234” then I want it to be replaced with “Bracket 2345”.

I see examples that this is possible if I have local rules and use the "place ilogic component"-function. But this requires some preparations...

Is it possible to use an ilogic rule that checks through the BOM, find a part with Title "Bracket 1234" and make it replace this

 

(I do not want to change the node-names).

 

Is this possible? And does anyone have an example.

If it is possible is it also possible to manage this with assemblies with more levels (more than one level of assemly)

Best regards
TG

Autodesk Inventor/Vault Professional 2021

3 main ideas should be mentioned.

 

Step 1 

You should scan AssmblyDocument.AllReferencedDocuments collection to find if your “Bracket 1234” part is used in the active assembly. You may check iProperties, parameters, attributes, filenames, etc. to identify your part.

 

Step 2
If “Bracket 1234” part document was found you may find all occurrences for this PartDocument:

 

'find all occurrences for every part found
Dim oOccEnum As ComponentOccurrencesEnumerator
Set oOccEnum = oAsmDoc.ComponentDefinition.Occurrences.AllReferencedOccurrences(oPartDocument)

This oOccEnum collection will contain all occurrences (from all hierarchy levels), so you do not need to traverse recursively the top-level assembly tree.

 

Step 3 

Each component in the oOccEnum collection may be replaced by another component using ComponentOccurrence.Replace method.

 

If you prefer iLogic then you may consider the following function:

Component.Replace(“ComponentToReplaceName”, “OtherPartfilename.ipt”, <replaceAll>)

 

The third Boolean argument allows you to replace all instances of this component or just the single named instance.

http://help.autodesk.com/view/INVNTOR/2015/ENU/?guid=GUID-AFA099F1-B161-4822-914D-307F5CD8FE20

 

Hope this helps.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network