Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WRahmanK
355 Views, 3 Replies

Calculate Length, width and Thickness

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