BoundingBox method
Returns a rectangle that tightly encloses a shape, or the shapes of a page, master, or selection.
Version added
4.5
Syntax
| |
object |
Required. An expression that returns the Page, Master, Shape or Selection object whose bounding box is to be retrieved. |
flags |
Required Integer. Flags that influence the bounding box calculated for each shape that contributes to the resulting bounding box. |
left |
Required Double. Returns x-coordinate of left edge of bounding box. |
bottom |
Required Double. Returns y-coordinate of bottom edge of bounding box. |
right |
Required Double. Returns x-coordinate of right edge of bounding box. |
top |
Required Double. Returns y-coordinate of top edge of bounding box. |
Remarks
For a Shape object, the BoundingBox method returns a rectangle that tightly encloses the shape and its sub-shapes.
For a Page, Master, or Selection object, the BoundingBox method returns a rectangle that tightly encloses the page's, master's, or selection's shapes and their sub-shapes.
If the BoundingBox method returns an error, or if it is asked to return the rectangle enclosing zero shapes, the rectangle returned is { left: 0, bottom: 0, right: -1, top: -1 }; otherwise, the rectangle returned has left less than or equal to (<=) right and bottom less than or equal to (<=) top. The numbers returned are in internal units (inches).
The bounding rectangle returned for an individual shape depends on its Type property.
Constant |
Description |
visTypePage |
Equivalent to Page.BoundingBox or Master.BoundingBox. |
visTypeGroup |
Rectangle that tightly encloses the group and its sub-shapes. |
visTypeShape |
Determined rectangle depends on flags. See below. |
visTypeForeignObject |
Determined rectangle depends on flags. See below. |
visTypeGuide |
Determined rectangle depends on flags. See below. |
The method will raise an exception for object type visTypeDoc.
The flags argument has several bits that control the bounding box retrieved for each shape. If more than one of the bits described below is set, the rectangle determined for the shape covers all rectangles implied by the bits.
Flag |
Value |
Description |
visBBoxUprightWH |
&H1 |
Return a rectangle that is the smallest rectangle parallel to the local coordinate system of the shape's parent that encloses the shape's width-height box. If the shape is not rotated, its upright width-height box and its width-height box are the same. Paths in the shape's geometry needn't and often don't lie entirely within the shape's width-height box. |
visBBoxUprightText |
&H2 |
Return a rectangle that is the smallest rectangle parallel to the local coordinate system of the shape's parent that encloses the shape's text. |
visBBoxExtents |
&H4 |
Return a rectangle that is the smallest rectangle parallel to the local coordinate system of the shape's parent that encloses the paths stroked by the shape's geometry. This may be larger or smaller than the shape's upright width-height box. The extents box determined for a shape of type visTypeForeignObject equals that shape's upright width-height box. |
visBBoxIncludeHidden |
&H10 |
Include hidden geometry. |
visBBoxIgnoreVisible |
&H20 |
Ignore visible geometry. |
VisBBoxIncludeGuides |
&H1000 |
Include extents for shapes of type visTypeguide. By default, the extents of shapes of type visTypeGuide are ignored. If you request guide extents, then only the x positions of vertical guides and the y positions of horizontal guides contribute to the rectangle that is returned. If any vertical guides are reported on, an infinite y extent is returned. If any horizontal guides are reported on, an infinite x extent is returned. If any rotated guides are reported on, infinite x and y extents are returned. |
visBBoxDrawingCoords |
&H2000 |
Return numbers in the drawing coordinate system of the page or master whose shapes are being considered. By default, the returned numbers are drawing units in the local coordinate system of the parent of the considered shapes. |
visBBoxNoNonPrint |
&H4000 |
Ignore the extents of shapes that are non-printing. A shape is non-printing if the value of its NonPrinting cell is non-zero or it belongs only to non-printing layers. |
The extents rectangle is determined using the center of the shape's strokes; it does not take into account the width of the strokes. Nor does the rectangle include any area covered by shadows or line end markers. Visio doesn't expose a means to determine a shape's "black bits" box, that is, the extents box adjusted to account for stroke widths, shadows, and line ends.
A shape may have control points or connection points that lie outside any of the bounding rectangles reported by the shape. You can determine the position of control points and connection points by querying results of the shape's cells.