Calculate Length, width and Thickness

Calculate Length, width and Thickness

WRahmanK
Participant Participant
531 Views
3 Replies
Message 1 of 4

Calculate Length, width and Thickness

WRahmanK
Participant
Participant

Hi,

I am trying to calculate the length, width and thickness of a Plate,

WRahmanK_0-1703568700622.png

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


0 Likes
532 Views
3 Replies
Replies (3)
Message 2 of 4

jeremy.goenen
Advocate
Advocate

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

 

Fanden Sie diesen Beitrag hilfreich? Fühlen Sie sich frei, diesen Beitrag zu liken.
Wurde Ihre Frage erfolgreich beantwortet? Klicken Sie dann auf die Schaltfläche LÖSUNG AKZEPTIEREN

Inventor Versionen:
2025.2
Message 3 of 4

WRahmanK
Participant
Participant

Thanks for the effort you put into this...
I cannot find 'OrientedMinimumRangeBox' API under ComponentDefinition 

WRahmanK_2-1704031887368.png

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...

0 Likes
Message 4 of 4

bradeneuropeArthur
Mentor
Mentor

What version of Inventor are you using? Oriented rangebox has been implemented in later versions of Inventor.

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


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:
My 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 !


 


EESignature

0 Likes