Get model dimensions using Inventor API or iLogic

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.83 | 34.8643055 |
32.817 | 27.3675394 |
96 | 96 |
Model 2:
program (in) | iLogic (in) |
18.7504 | 18.75 |
16.768 | 16.7287 |
3.828 | 2.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.