Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dimensions of rectangular prism

3 REPLIES 3
Reply
Message 1 of 4
pcrawley
643 Views, 3 Replies

Dimensions of rectangular prism

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
3 REPLIES 3
Message 2 of 4
philippe.leefsma
in reply to: pcrawley

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
in reply to: philippe.leefsma

Thanks Philippe.  I'll give that a try.

Peter
Message 4 of 4
pcrawley
in reply to: pcrawley

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report