Get model dimensions using Inventor API or iLogic

Get model dimensions using Inventor API or iLogic

Anonymous
Not applicable
2,650 Views
2 Replies
Message 1 of 3

Get model dimensions using Inventor API or iLogic

Anonymous
Not applicable

Hi All,

 

I'm trying to get the dimensions (length, breadth, height) of all the models referenced in an assembly. I'm planning to do this using either Inventor API or Apprentice API reading the BOM of the main assembly and opening each model in Inventor and executing something similar to the below code (source from Justin's reply in this thread - https://forums.autodesk.com/t5/inventor-customization/measure-extentslength-from-a-part-to-drawings/...).

 

var compDef = assemblyDoc.ComponentDefinition;
var rangeBox = compDef.RangeBox;

 

MessageBox.Show("Unit is " + assemblyDoc.UnitsOfMeasure.GetStringFromType(assemblyDoc.UnitsOfMeasure.LengthUnits));

//to do: make changes based on units

//by default the values are in cm, convert to inches

var length = (rangeBox.MaxPoint.X - rangeBox.MinPoint.X) / 2.54;
var width = (rangeBox.MaxPoint.Y - rangeBox.MinPoint.Y) / 2.54;
var height = (rangeBox.MaxPoint.Z - rangeBox.MinPoint.Z) / 2.54;
MessageBox.Show(length + Environment.NewLine + width + Environment.NewLine + height);

 

 

But when I run the below ilogic rule on random models to check the output, for some models some dimensions differ by 1 or 2 inches

SyntaxEditor Code Snippet

MessageBox.Show(Measure.ExtentsLength, "Length")
MessageBox.Show(Measure.ExtentsWidth, "Width")
MessageBox.Show(Measure.ExtentsHeight, "Height")

Model1:

program (in)iLogic (in)
35.8334.8643055
32.81727.3675394
9696

 

Model 2:

program (in)iLogic (in)
18.750418.75
16.76816.7287
3.8282.9295

 

My questions are:

 

1. Why this difference in dimensional values? I checked the work features on these models, they were turned off.

2. Is there a better solution for my original problem? Get the dimensions (length, breadth, height) of all the models referenced in an assembly.

 

 

Thanks

Rekha.

0 Likes
2,651 Views
2 Replies
Replies (2)
Message 2 of 3

b_sharanraj
Advocate
Advocate

Hi @Anonymous

 

Is it possible to upload your model?

Regards

B.Sharan Raj

0 Likes
Message 3 of 3

b_sharanraj
Advocate
Advocate

The values which you got by iLogic will be the right one.

 

I can see that via program you are trying to measure the Length, Width & Height of parts in assembly itself.

 

Try by opening each part from assembly and measure the Length, Width & Height of Active Document. Then compare the values with iLogic it'll match.

 

Regards

B.Sharan Raj

0 Likes