- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Calculate Length, width and Thickness
Hi,
I am trying to calculate the length, width and thickness of a Plate,
Below is my code to calculate the length, Width & Thickness,
Inventor.Point maxpoint = Pdoc.ComponentDefinition.RangeBox.MaxPoint;
Inventor.Point minpoint = Pdoc.ComponentDefinition.RangeBox.MinPoint;
Inventor.Point2d p1 = InvApp.TransientGeometry.CreatePoint2d(0, 0);
Inventor.Point2d p2 = InvApp.TransientGeometry.CreatePoint2d(0, 0);
PlanarSketch sk = null;
List<double> db = new List<double>();
double[] arr = { maxpoint.X - minpoint.X, maxpoint.Y - minpoint.Y, maxpoint.Z - minpoint.Z };
//double[] arr = { p2.X - p1.X, p2.Y - p1.Y, 0 };
Array.Sort(arr);
db.Sort();
for (int i = 0; i < arr.Length; i++)
{
if (arr[i] < 0) { arr[i] = arr[i] * -1; }
}
double G_L = arr[2] * 10; //dbmax[dbmax.Count - 1] * 10;//
double G_W = arr[1] * 10; //dbmax[dbmax.Count - 2] * 10;
double G_H = arr[0] * 10; //db[0] * 10;
if the plate is aligned to any Default plane, I am getting the Length, Width & Thickness correctly, if the plate is not aligned to any Default Plane, then there is some outer boundary generated due to which the above code output wrong length, Width and Thickness.
Could anyone advice how to get only particular solid bodies and then calculate the length, width and Thickness, or any other best method to calculate these values.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, you could use the OrientedMinimumRangeBox. In a Multibodypart you would then specify the body.
Dim compdef As ComponentDefinition = ThisDoc.Document.ComponentDefinition Dim minimumboundingbox As OrientedBox = compdef.OrientedMinimumRangeBox Dim dir1, dir2, dir3 As Double dir1 = Round(minimumboundingbox.DirectionOne.Length, 1) *10 dir2 = Round(minimumboundingbox.DirectionTwo.Length, 1) *10 dir3 = Round(minimumboundingbox.DirectionThree.Length, 1) * 10 ' '----------Show axis If needed---------- 'origin = compdef.WorkPoints.AddFixed(minimumboundingbox.CornerPoint) : origin.Name = "origin" 'dir1axis = compdef.WorkAxes.AddFixed(minimumboundingbox.CornerPoint, minimumboundingbox.DirectionOne.AsUnitVector) : dir1axis.Name = "dir1axis" 'dir2axis = compdef.WorkAxes.AddFixed(minimumboundingbox.CornerPoint, minimumboundingbox.DirectionTwo.AsUnitVector) : dir2axis.Name = "dir2axis" 'dir3axis = compdef.WorkAxes.AddFixed(minimumboundingbox.CornerPoint, minimumboundingbox.DirectionThree.AsUnitVector) : dir3axis.Name = "dir3axis" length = MaxOfMany(dir1, dir2, dir3) width = MinOfMany(dir1, dir2, dir3) height = (dir1 + dir2 + dir3) -length - width
Wurde Ihre Frage erfolgreich beantwortet? Klicken Sie dann auf die Schaltfläche LÖSUNG AKZEPTIEREN
Inventor Versionen:
2023.4.3
2025.2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Thanks for the effort you put into this...
I cannot find 'OrientedMinimumRangeBox' API under ComponentDefinition
I think some dll reference need to be added to include Autodesk.Ilogic.Runtime header in the coding...
if am i right please tell me what reference to add or else please help me with any possible solution...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
What version of Inventor are you using? Oriented rangebox has been implemented in later versions of Inventor.
Regards,
Arthur Knoors
Autodesk Affiliations:
Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!
! For administrative reasons, please mark a "Solution as solved" when the issue is solved !