Get bounding box for multibody part?

Hi,

Not long ago I tweaked a macro to get the bounding box of an assembly using the 'GetBox' Method.

2015 SOLIDWORKS API Help - GetBox Method (IComponent2)

Does anyone know what the equivalent function is for a part containing multibodies? I know how to get bounding box dimensions for individual bodies from the cutlist, but not the OVERALL dimensions of the part.

Any ideas?

SolidworksApi macros
Answers 8
AT
AT 2017-08-31 Best Answer

Hello Raymond,

Wouldn't it be easy just to convert the solidbodies into weldment by selecting the weldment feature button and then RC on the cutlist and create bounding box?

Alen

RY
RY 2017-08-31

Hi Alen,

Maybe I didn't explain myself too well in my question. The part in most cases will contain a weldment feature since at least one of the bodies in the multibody part is a weldment profile. For example, below is a box surrounded with 3 weldment profiles. I can create a bounding box and pluck their overall dimensions from each cutlist item individually, but what I'm after is the OVERALL dimension.

As mentioned in the first question, the 'GetBox' method in the assembly environment gets the Max/Min values from all 3 global axis. I just thought there might be something similar in the part environment?

comment imagecomment image
AT
AT 2017-08-31

Hello Raymond,

So I have another solution for you, just create either a solid or sheet metal thin extrusion that references the overall perimeter and use that to monitor the overall Length and Width of the model. There are also other nicer ways using custom property tab builder which is tied to the sketch which we can hide and we can program it such that its constantly updating and writing to file properties.

References Part Monitoring

Custom Properties

Two ways, which one you like is up to you

Alen

comment imagecomment imagecomment imagecomment image
AJ
AJ 2017-09-02

Without having to add any unnecassary steps, why don't you get the bounding box of all bodies and determine the lowest X and Y (that's the lowest corner) and likewise for the highcorner? All of your bodies bounding boxes will have (Pxmin, Pymin) and (Pxmax, Pymax).

Cheers,

Amen

CADHERO consulting SUARL – CAD Design Automation & Training – SOLIDWORKS API

SA
SA 2017-09-02

Go into the API help and search for example "Get Part Bounding Box Example (VBA)".  (I am using SW2016)

I suggest changing the call for getting SolidWorks to "Set swApp = Application.SldWorks"

The macro generates two ways to get the bounding box.  And it works on weldments too!

See if this works for you.

TR
TR 2019-10-03

Try the GetPartBox method.

2019 SOLIDWORKS API Help - GetPartBox Method (IPartDoc) 

Note that all the macro versions of the bounding boxes get a box orthogonal to the coordinate system.  The built-in reference geometry feature is better in that it rotates the box to make it smaller for off-angle parts/assemblies/weldments.

 

SL
SL 2019-10-03

My method is to use planes. I make assembly driven models of sheet metal box's that are seal welded into tanks.

I offset X Y and Z planes as the first step in an assembly. Then make all the sketches inside the parts a function of the plane positions in the assembly.

DS
DS 2019-10-03

Insert...Reference Geometry...Bounding Box

Then look in the Config Specific properties...

comment imagecomment image