Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iLogic: Call part by name in assembly

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
ad64
502 Views, 2 Replies

iLogic: Call part by name in assembly

How do I reference a part by it's name in the assembly within an iLogic rule?

 

Example Code:

 

    Dim oDoc As Inventor.AssemblyDocument = ThisApplication.ActiveDocument         'Current Document
    Dim oOcc As ComponentOccurrence 'Each Occurrence of a part or subassembly
    
    MsgBox(oDoc.ComponentDefinition.Occurrences("Test Part:1").Definition.Sketches.Count)

 

 

Even though a part with this name exists in the assembly, if I execute this code I get "Conversion from string "Test Part:1" to type 'Integer' is not valid.

 

Is there another way to reference parts in code by their name (other than a For... Next loop with an If statement).

 

Thanks,

Steve

2 REPLIES 2
Message 2 of 3
rjay75
in reply to: ad64

Message 3 of 3
ad64
in reply to: rjay75

Works great. Thanks.

 

Steve

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report