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: 

Distance between two parts/assembly.

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
gopinathmY575P
251 Views, 2 Replies

Distance between two parts/assembly.

Hello Community,

 

I'm looping through bom rows of an assembly environment.  i got output like below.

Level 4Level 5Level 6Level 7Level 8
Assly 1Assly 2Assly 3Assly 4Cylinder 1
Assly 1Assly 2Assly 5 Cylinder 2

i want distance between cylinder 1 and cylinder 2 based on its cg.

 

or if any other way, support with examples.

Labels (4)
2 REPLIES 2
Message 2 of 3

Hello @gopinathmY575P,

 

Knowing that the center of gravity of an occurrence is a point, we can use the distanceTo method to get the distance between the two points. Also, center of gravity of an occurrence is called Center of mass. Here an example that let's you pick two occurrences inside an assembly & calculate the distance between the two (default in cm) :

Dim occ1 As Inventor.ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "")
Dim occ2 As Inventor.ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "")

Dim cg1 As Point = occ1.MassProperties.CenterOfMass
Dim cg2 As Point = occ2.MassProperties.CenterOfMass

Dim distance As Double = cg1.DistanceTo(cg2) 'distance in cm!
MsgBox(distance)

 

Inventor 2022 Help | IiProperties.CenterOfGravity Property | Autodesk

 

Your question is not very precise, do you want to use the BOM to calculate ?

 

Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

Message 3 of 3

@FINET_Laurent  Thank you ...... its solved my issues.

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

Post to forums  

Autodesk Design & Make Report