The bounding box from any type of entity is returned as a Box3D object. The Box3D object returns the min and max points. The code below will get the length, width, and height where the length is the size along the X axis, width is the size along Y axis, and the height is the size along the Z axis. box is a variable that references a Box3D object.
length = box.maxPoint.x - box.minPoint.x width = box.maxPoint.y - box.minPoint.y height = box.maxPoint.z - box.minPoint.z
You also say that you want to get the bounding box of a component, which is possible, but I suspect you really want the bounding box of an occurrence, which is also possible. To understand the difference you can read this topic in the API Help.
Thank you @ekinsb,
I am happy! I was on the right track, but i used the Component.boundaryBox points. 🙂
One question. I have measured the component with Fusion UI "Inspect" tool.
My component is 150.00 x 87.00 x 20.00.
But the calculated boundary points are 150.02 x 87.01 x 20.03.
Is that because i used the Component instead of the Occurrence object?
Hope my english is understandable 🙂
A bounding box isn't guaranteed to be a tight fit to the graphics. The only guarantee is that the object is entirely contained within the bounding box. Because of this it's best not to use the bounding box for measurements. It's typically used when you need to compare multiple entities and the bounding box is an efficient first check to see if those entities possibly overlap before doing more complex calculations.
Although for simple graphics I would expect it to be a tight fit. I think we need to look into this and seem why it's not tighter. Technically, what you're getting back is correct because the occurrence is contained within the bounding box but it would be better to be tighter when possible.