Returns a cell array containing the bounding box for an object(s) in SI units with an optional argument to first make a hypothetical transformed copy.
If a group is selected, the bounding box is for all objects in the group.
If the bounding boxes of any objects overlap, their boxes are combined. Non-overlapping bounding boxes are each returned as a separate element in the cell array.
Each bounding box is described by a 2x3 matrix as follows, with all values in SI units:
$$\begin{bmatrix}
x_{min} & y_{min} & z_{min}\\
x_{max} & y_{max} & z_{max}
\end{bmatrix}$$
| Syntax | Description |
|---|---|
| boundingbox; | Returns a cell array containing the bounding box of the selected object(s). |
| boundingbox(obj_name); | Returns a cell array containing the bounding box of an object with name obj_name. |
| boundingbox(props_struct) |
Uses props_struct to first construct a hypothetical transformed copy of the selected object and returns the bounding boxes for both the original and transformed objects. No changes are made to the object in the object tree. If the bounding box of the transformed copy overlaps with the original in any way, the overlap rules apply. |
| boundingbox(obj_name , props_struct) |
Uses props_struct to first construct a hypothetical transformed copy of an object named obj_name and returns the bounding box(es) for both the original and transformed objects. No changes are made to the object in the object tree. If the bounding box of the transformed copy overlaps with the original in any way, the overlap rules apply. |
Example
Bounding box of a single object
#Single object
addrect({"name":"MyRect1","x": 0e-6, "x span":3e-6,"y": 0e-6, "y span":3e-6, "z": 0e-6, "z span":3e-6});
out = boundingbox("MyRect1");
?out{1};Bounding box for two non-overlapping objects
#Non overlapping multiple objects
addrect({"name":"MyRect1","x": 0e-6, "x span":3e-6,"y": 0e-6, "y span":3e-6, "z": 0e-6, "z span":3e-6});
addrect({"name":"MyRect2","x": 10e-6, "x span":3e-6,"y": 1e-6, "y span":3e-6, "z": 1e-6, "z span":3e-6});
selectpartial("MyRect"); #Select both objects
out = boundingbox;
?length(out);
for (i=1:length(out)){
?out{i};
}Bounding box for a single object with a hypothetical transform
# Incorporate a hypothetical transformed of the first that is centered at x=1e-6, the x-span of the bounding box is from -1.5e-6 to 2.5e-6, as the transformed object overlaps with the original
addrect({"name":"MyRect1","x": 0e-6, "x span":3e-6,"y": 0e-6, "y span":3e-6, "z": 0e-6, "z span":3e-6});
transform_struct = {"x":1e-6};
out = boundingbox("MyRect1", transform_struct);
?length(out);
for (i=1:length(out)){
?out{i};
}
See Also