Community
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Overall Bounding Box Size of Part or Assembly

Overall Bounding Box Size of Part or Assembly

It would be really nice to have the bounding box or overall length (X), width (Y), and height (Z) values of a part or assembly file as iProperties without having to measure or do it as an iLogic code. Then, these could be properties shown in a drawing file in the title block or note. 

 

This could be placed in the iProperties under the Physical tab:

Overall.png

36 Comments
admaiora
Mentor

The ability to obtain the 3 max measures of parts (overall dimenions) in an assembly in a simple way and not depending from the cartesian origin, and working fine with rotated parts too.

jmfowler1996
Advocate

This would be especially useful for BOMs. The number of times I have seen incorrect/outdated sizes in a manually created BOM is enough for this to this to be considered an expensive problem.

 

 

drew
Advocate

Obviously something needing attention or at least if already addressed since January needs better documentation. 

I'm using Fusion 360, not Inventor, but searching for ways to get an accurate bounding box on a component for use in a BOM got me this post.

 

Hey developer folks - please allow us to easily tell the software to "tighten" bounding boxes to the described object OR build in an option for 'true measure of object' when generating a BOM!

Anonymous
Not applicable

ChelseaJVH,

 

Try This iLogic rule:

 

'Get Component bounding box measurements
Model_X=Measure.ExtentsLength 'X-axis BB length
Model_Y=Measure.ExtentsWidth  'Y-axis BB length
Model_Z=Measure.ExtentsHeight 'Z-axis BB length'Add / Update Bounding Box measurements to model's Custom Properties
iProperties.Value("Custom", "ModelX")=Model_X
iProperties.Value("Custom", "ModelY")=Model_Y
iProperties.Value("Custom", "ModelZ")=Model_Z

Set the rule to run on Open / Save / Any Model Change

Hope this helps.

Marshallw
 

 

admaiora
Mentor

No.

 

It doesn't work for rotated parts.

 

ded.jpg

jmfowler1996
Advocate
Try this for aligned extents (will work for rotated parts):


Sub GetDocDims(oDoc As Document, ByRef Length As String, ByRef Width As String, ByRef Thickness As String)

'Grab range box of each surface body and combine to get the max range box
'Get the overall dims using the rangebox max/min points
'Sort these overall dims from smallest to largest and assign as length width and thickness

Dim oCompDef As ComponentDefinition
oCompDef = oDoc.ComponentDefinition

Dim uom as UnitsOfMeasure = oDoc.UnitsOfMeasure

Dim minp As point
Dim maxp As point

Dim oRB As Box
Try
For Each sb In oCompDef.SurfaceBodies
If oRB Is Nothing Then
oRB = sb.RangeBox.Copy
Else
oRB.Extend(sb.RangeBox.MinPoint)
oRB.Extend(sb.RangeBox.MaxPoint)
End If
Next

minp = oRB.minPoint
maxp = oRB.maxPoint
Catch ex As Exception
MessageBox.Show("Error finding extensions for part: " & partName, "iLogic")
Exit Sub
End Try

'Get part dimensions
dp=0
X = Round(uom.ConvertUnits ((maxP.X - minP.X), "cm", uom.LengthUnits), dp)
Y = Round(uom.ConvertUnits ((maxP.Y - minP.Y), "cm", uom.LengthUnits), dp)
Z = Round(uom.ConvertUnits ((maxP.Z - minP.Z), "cm", uom.LengthUnits), dp)

Dim extents As New ArrayList()
extents.add(X)
extents.add(Y)
extents.add(Z)

extents.Sort()

Thickness = extents(0)
Width = extents(1)
Length = extents(2)

End Sub


Done as part of my project here: https://forums.autodesk.com/t5/inventor-customization/an-ilogic-rule-from-me-to-you/m-p/7069140

Sorry for bad formatting. I'm replying from my phone.
ChelseaK_D3
Enthusiast

marshallw,

I know that it would be possible to code this but I posted it here because it would just be nice to have it as a default property that was available. 

 

Thanks!

admaiora
Mentor

Hi @jmfowler1996 can you attach a working ipt + rule ?

 

 

Thank you!

jmfowler1996
Advocate

@admaiora

That iLogic was from a rule to be run from a drawing document. And to clarify, it finds extents based on the part's user coordinate system. It will not work for parts whose UCS does not align with the rangebox you are wanting (e.g. if for some reason you create a cube which sits on one vertex instead of a face, it won't give you the minimum dimensions of the cube). It does work for rotated parts in an assembly though.

If you are still interested in using it, I suggest you go to the post I linked earlier, scroll to the bottom and take that whole rule to modify for your application.

If you are looking for a rule which will find the minimum dimensions of a part which is not aligned to its UCS, then I'm afraid I don't have a solution, and I think any rule which could do that would need to be pretty complex! Sorry.

DRoam
Mentor

Here's a related Idea you can vote for, dealing specifically with non-aligned/non-orthogonal parts: Minimum Bounding Box of non-aligned Parts.

 

Currently, there doesn't seem to be a good, robust way to get the minimum bounding box for non-orthogonal parts. This is a complex geometry problem, and not likely something we'll be able to implement on our own using iLogic/API. Here is a paper discussing a mathematically rigorous, exact algorithm for calculating minimum bounding box: An Exact Algorithm for Finding Minimum Oriented Bounding Boxes by Jukka Jylanki. As you can see, it's not a simple task.

 

I've done a lot of searching for workarounds for this, and tried to come up with my own, but I have yet to come across an acceptable one. All workarounds are both tedious and unstable.

 

So, hopefully the Inventor devs will be willing to tackle this in the near future.

admaiora
Mentor

Great DRoam, I agree with you!

Anonymous
Not applicable

I was just about to post a similar idea, then found this, so it looks like I'm not alone in wanting this feature. 

I recently introduced a colleague to Inventor as a means of creating packaging models to determine how many parts can be fitted into a stillage for heat treatment. He previously used a product called Spinfire to view STEP files provided by his customers. This enabled him to view the STEP files but not much else.

 

One very useful feature of Spinfire however, was its ability to display a bounding box with dimensions around the part being displayed. I love ChelseaK's idea of including it in iProperties, but if Inventor could work like Spinfire and have a tickbox to enable display of the bounding box around the part, then not only would you have the envelope dimensions, but you would be able to view them in context, which is important in my colleague's application, where orientation of the part in the stillage can be critical.

iva.btblan
Advocate
We ask for added innovation.
We've lost a lot with this activity.
Packaging several pieces into containers.
We'il Be happy!
Thank you!
 
Iva.btblan
swalton
Mentor

See existing Idea:

https://forums.autodesk.com/t5/inventor-ideas/overall-bounding-box-size-of-part-or-assembly/idi-p/67...

 

There is some iLogic code in that Idea post that may help while you wait to see if Autodesk will implement this idea.

iva.btblan
Advocate

Excellent!
It will be a wonderful option to help us.
Our work will be quicker.
We have several similar situations.
Iva.btblan

Anonymous
Not applicable

Hello Mr. Marshallw,

 

I want to use your code, but only getting "0," in all 3 dimensions.

 

 
'Get Component bounding box measurements
Model_X=Measure.ExtentsLength 'X-axis BB length
Model_Y=Measure.ExtentsWidth  'Y-axis BB length
Model_Z=Measure.ExtentsHeight 'Z-axis BB length'Add / Update Bounding Box measurements to model's Custom Properties
iProperties.Value("Custom", "ModelX")=Model_X
iProperties.Value("Custom", "ModelY")=Model_Y
iProperties.Value("Custom", "ModelZ")=Model_Z

Set the rule to run on Open / Save / Any Model Change

Hope this helps.

Marshallw

 

 

 

jmfowler1996
Advocate

@Anonymous 

I remember having a very similar problem, which turned out to be a units problem. e.g. it may be that the past is 450mm long, but the units are set to metres so it's displayed as 0m long. That might not be what's going on but it's worth looking into. If so, make sure to convert the units as required.

Anonymous
Not applicable

@jmfowler1996  I tested the ilogic for bounding box. It promted me to "Select A Drawing Curve". But I cannot select any curve in my drawing.  Thank you.

jmfowler1996
Advocate

@Anonymous 

Please be aware that the code won't work for parts which are not aligned with their own origin planes.

I have changed this code quite a lot since the version I posted so I can't be sure that it works perfectly, especially on more recent versions of inventor like 2020+.

That said, picking the drawing curve should work fine. Make sure you're running the rule from a .idw file, make sure you're picking a line which represents 3D model geometry (not a line of a 3D sketch).

dba78
Advocate

As of parts, there is a built-in solution (introduced in 2016). Unfortunately it's not documented in the API-Help

There is a property called 'OrientedMinimumRangeBox' available on the Surfacebody-object. This gives you a corner Point and the three vectors of the box edges (independent from the coordinate System). Essentially, the vector length give you the dimension in that given direction. I know, OP asked for iLogic, but you see the idea 🙂

 

Sub box()

Dim minBox As OrientedBox
Dim doc As PartDocument
Dim cd As PartComponentDefinition

'active document is a part with at least one body
Set doc = ThisApplication.ActiveDocument
Set cd = doc.ComponentDefinition

'for multibody you need to merge the bodies via transientBrep to a transient surfacebody
'OrientedBox has no 'Add' method, or whatsoever

Set minBox = cd.SurfaceBodies(1).OrientedMinimumRangeBox
Width = minBox.DirectionOne.Length
Height = minBox.DirectionTwo.Length
Depth = minBox.DirectionThree.Length

End Sub

 

For an assembly you will need to collect the Surfacebodies of the Components (AllLeafOccurrences), and merge them together with TransientBrep... Or derive the assembly to one merged body. Performance drops quickly as the assembly gets larger, however 😕

 

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

Submit Idea  

Autodesk Design & Make Report