Using Alignment Boxes to Snap Shapes to a Grid
When a user drags a shape into the drawing window, by default the shape's selection rectangle, or alignment box, is snapped to the nearest grid line. (If snapping is turned off for a document, Microsoft® Visio® positions the shape where it was dropped.) All shapes have an alignment box, which by default is the same size as the shape's width-height box. If a shape is asymmetrical or composed of odd-sized components, users might find it harder to predict its alignment and snapping behavior. Or you might want parts other than the outer edges of the shape to snap to the grid. You can customize a shape's alignment box to clarify its intended use.
If a shape is rotated at an angle that is not a multiple of 90 degrees, the alignment box is the smallest upright rectangle that contains all of the paths of the shape as if their line thickness were set to zero.
In this section
Adjusting the Size of a Shape's Alignment Box
You can customize the size of an alignment box for a shape. For example, you can design a series of different shapes with same-sized alignment boxes so that they snap and align correctly, as the following figure shows.
To create an alignment box that is distinct from a shape's geometry, you draw the alignment box first, and then prevent Visio from changing it as you create and edit the shape's geometry.
To define an alignment box that differs from the width-height box
- Draw your shape.
- Select the shape, and then click Show ShapeSheet on the Window menu.
- In the Protection section, set the formula for the LockCalcWH cell to true (or 1).
- This setting preserves the current alignment box so that it won't change as you define the shape's geometry.
- Use the Pencil, Line, Arc, or Rectangle tool (not the Pointer tool) to add to or modify the shape's geometry.
Enclosing a shape in a larger alignment box
You can enclose a shape in an alignment box that's larger than its width-height box. This can make the shape easier for users to snap to the grid. For example, the symbol for an electrical outlet is a rectangular shape enclosed in a larger, square alignment box to make it easier to position the shape.
To enclose a shape in a larger alignment box
- Draw one shape, and then draw another shape that is the size you want for the larger alignment box.
- Select the two shapes. On the Shape menu, point to Grouping, and then click Group.
- Select the group. On the Edit menu, click Open Group, and then delete the alignment box shape from the group.
Customizing a group's alignment box
You can customize the size of a group's alignment box to make your master easier for users to snap and align. When a master is a group of one or more shapes, the group supplies the alignment box. For some shapes, the default group alignment box would not align the shape appropriately. In the following figure, the shape is a group with a custom alignment box.
To create a group with a custom-sized alignment box
- Construct the separate shapes that will make up the master. Don't customize formulas for these shapes yet.
- Use the Rectangle tool to create a shape the size and position of the desired alignment box relative to the other shapes in the master.
- Select the alignment box only and group it (press CTRL+G), and then click Open Group on the Edit menu to open it in the group window.
- Select the other shapes you want to add to the group, drag them into the group window, and position them relative to the alignment box.
- Delete the alignment box shape, and then close the group window.
- Add custom formulas to the shapes as desired.
Updating an Alignment Box
A shape's alignment box might no longer coincide with its width-height box after you edit its vertices or, in a group, after you resize a shape, or add a shape to or delete one from the group. To explicitly realign the alignment box with the width-height box, on the Shape menu, point to Operations, and then click Update Alignment Box. (The LockCalcWH cell in the Protection section must be set to FALSE or 0 for this command to work).
If you define a control handle at a shape vertex, moving the control handle also changes the shape's geometry so that the alignment box no longer coincides with the width-height box. In this case, you can set the UpdateAlignBox cell in the Miscellaneous section to true so that the alignment box always resizes as the control handle is moved.
Changing the Alignment Box for 1-D Shapes
By default, a 1-D shape's endpoints are centered horizontally in its alignment box. By moving the begin point and end point within the shape's local coordinate space, you can change the alignment box and make it easier for users to align your shape. For example, the following figure shows a 1-D wall shape with endpoints at the wall's edge, rather than its center. When users drag the shape, the line of the alignment box follows the edge used to connect the wall.
To move the alignment box for a 1-D shape
- With the Rectangle tool, draw the shape.
- Select the shape. On the Format menu, click Behavior.
- On the Behavior tab, select Line (1-dimensional), and then click OK.
- On the Window menu, click Show ShapeSheet.
- In the Shape Transform section, type 0 in. in the LocPinY cell.
- Moving the y-position of the local pin aligns the endpoints with the shape's edge.
Tip You can hide the alignment box of a 1-D shape such as a connector if displaying it would interfere with the shape's function. On the Format menu, click Behavior, and then clear the Show alignment box check box. Or set the NoAlignBox cell to true in the Miscellaneous section.