Dimensions of rectangular prism

Dimensions of rectangular prism

pcrawley
Advisor Advisor
770 Views
3 Replies
Message 1 of 4

Dimensions of rectangular prism

pcrawley
Advisor
Advisor

Happy new year everyone.  

 

Can anyone help me with a problem regarding obtaining the dimensions of a simple retangular prism?

 

In this particular case (file attached) the geometry was imported from Revit, so it's really just imported SAT file.  After importing, "Make components" was run to generate individual part files.  The resulting part is therefore created using the origin of the parent assembly, so although it's "just a box" - it is spatially displaced and oriented at an unknown angle.

 

I'm looking for a way to identify the 3 dimensions that define the shape of the prism.

Any ideas?

Peter
0 Likes
771 Views
3 Replies
Replies (3)
Message 2 of 4

philippe.leefsma
Alumni
Alumni

Hi Peter,

 

The only way I can think of would be to use the direction of the edges. This should be pretty straighforward, you can access each Vertex.Geometry which returns a LineSegment that has a direction.

 

I hope it helps,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 4

pcrawley
Advisor
Advisor

Thanks Philippe.  I'll give that a try.

Peter
0 Likes
Message 4 of 4

pcrawley
Advisor
Advisor

If anyone else needs this, here's what I ended up with (using iLogic).

It appears to be working perfectly.  Thanks again for suggesting a starting point Philippe.

 

 

 

Dim oCompDef As PartComponentDefinition
oCompDef = ThisApplication.ActiveDocument.ComponentDefinition
oBody = oCompDef.SurfaceBodies.Item(1)
oEdges = oBody.Edges

Dim oStart As Point 'Will contain x,y,z locations of edge start
Dim oEnd As Point 'Will contain x,y,z locations of edge end
Dim oLength As New ArrayList 'To store each edge-length once calculated

'Probably need error trapping here if Edges.Count <> 12!

For i = 1 To oEdges.Count

oStart = oEdges.Item(i).Geometry.StartPoint
oEnd = oEdges.Item(i).Geometry.EndPoint
oCalcLength = Sqrt((oStart.x-oEnd.x)^2 + (oStart.y-oEnd.y)^2 + (oStart.z-oEnd.z)^2) 'Calc's length from start/end.
oCalcLength = Round(oCalcLength,5) * 10 'Round and convert to mm.
oLength.Add(oCalcLength) 'Store length in an array

Next

oLength.sort() 'Sort the list of results
Thickness = oLength(1) 'Array entries 1~4 will be the 4 shortest lengths.
Width = oLength(5) '5~8 will be mid-sized.
Length = oLength(9)'9~12 will be longest.

MessageBox.Show("Length = " & Length & vbLf & "Width = " & Width & vbLf & "Thickness = " & Thickness)

Peter
0 Likes