Part-Aligned Extents

Part-Aligned Extents

jmfowler1996
Advocate Advocate
490 Views
1 Reply
Message 1 of 2

Part-Aligned Extents

jmfowler1996
Advocate
Advocate

Hi.

 

I've been adding some features to our drawing template.

One handy iLogic code I've added gets the extents of a selected part in an assembly,

which are then used to create a default description for the part.

 

Unfortunately, sometimes the extents don't show accurate measurements.

I found this is due to the rangebox being aligned with the assembly's UCS as opposed to the UCS of the part itself:

 

Rear Protector.jpg

In the above case, the extents would show a much smaller height for the padeye, since it is at an angle in the assembly.

 

My question is: is there a way to get the extents of the part's rangebox, with the extents aligned to the part's UCS?

 

Currently, I get the extents like this:

 

'get the bounding box
oRB
= oOcc.RangeBox 'oOcc is the component occurrence.

'declare min and max points
Dim minp As point = oRB.minPoint
Dim maxp As point = oRB.maxPoint

'find difference between min and max points
X = Round(uom.ConvertUnits ((maxP.X - minP.X), "cm", uom.LengthUnits), 0)

 

 

Thanks! 

0 Likes
Accepted solutions (1)
491 Views
1 Reply
Reply (1)
Message 2 of 2

jmfowler1996
Advocate
Advocate
Accepted solution

For anyone with the same problem:

 

assuming you have already named the component definition 'oCompDef', and a range box as 'oRB',

you can use this code to fit the range box to the part's geometry (excludes work planes etc. too!)

 

        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

 This has the rangebox aligned with the part's UCS.