<?xml encoding=”UTF-8″>By Adam Nagy
By design the RangeBox of ComponentDefinition includes everything that the ComponentDefinition has. This also means the WorkPlane/WorkAxis objects, the ones owned by the Center of Gravity object too.
If you are only interested in the solid geometry then you could check the extents of the surface bodies as done by this VBA code:
Sub GetExtents()
Dim doc As Document
Set doc = ThisApplication.ActiveDocument
Dim cd As ComponentDefinition
Set cd = doc.ComponentDefinition
Dim ext As Box
Dim sb As SurfaceBody
For Each sb In cd.SurfaceBodies
If ext Is Nothing Then
Set ext = sb.RangeBox.Copy
Else
ext.Extend sb.RangeBox.MinPoint
ext.Extend sb.RangeBox.MaxPoint
End If
Next
MsgBox "Extensions are: " + vbCr + _
"X " + CStr(ext.MaxPoint.x - ext.MinPoint.x) + vbCr + _
"Y " + CStr(ext.MaxPoint.y - ext.MinPoint.y) + vbCr + _
"Z " + CStr(ext.MaxPoint.Z - ext.MinPoint.Z)
End Sub

Leave a Reply