Using SmartShapes Technology to Develop Shapes

Using Microsoft® Visio® SmartShapes® technology, you can develop shapes that behave like the objects they represent in the real world, modeling the characteristics that are meaningful for the kinds of drawings or diagrams you need to create. You do this by defining formulas that make the shapes behave the way they should according to the design rules, codes, or principles that apply to the corresponding objects.

Every Visio shape has its own ShapeSheet® spreadsheet, which defines the shape's unique behavior and capabilities. Think of the ShapeSheet spreadsheet as the property sheet of a shape, in which each property is set by a value or formula that is recalculated dynamically as the user works with the shape. You can view and edit a shape's formulas in the ShapeSheet window.

Many features that you might expect to require external programming can be controlled through the ShapeSheet window. For example, you add menu items to a shape's shortcut menu by defining formulas for the shape in the ShapeSheet window. Formulas can control other attributes of a shape, such as:

  • Geometry (flipping, rotation, visible or hidden paths)
  • Color, pattern, and line weight
  • Text, including font, paragraph formatting, and orientation
  • Control handles that help users adjust the shape
  • Connection points where other shapes can be glued
  • Custom properties that can contain user data

The spreadsheet interface makes it easy to use cell references to link one shape property to another, which means that shape properties can influence each other in subtle and powerful ways. For example, you might link the color of a shape, such as a part in a mechanical drawing, to its dimensions to indicate whether the part is within tolerance.

This arrow shape is a classic example of controlling a Visio shape with formulas. Its formulas override the default behavior given to shapes by the Visio engine, which is to size proportionately when the shape is stretched horizontally or vertically. When this arrow shape is sized horizontally, its custom formulas allow the tail to stretch or shrink horizontally but leave the arrowhead unchanged.

The arrow shape is controlled with Visio formulas

The arrow shape is controlled with Visio formulas.

  1. The base of the arrowhead is defined as a fraction of Height.
  1. All points on the base of the arrowhead have the same x-coordinate: Width - Height * 0.5
  1. Height
  1. Height * 0.75
  1. Height * 0.5
  1. Height * 0.25
  1. Width

For details about working in the ShapeSheet window and controlling shapes with formulas, see Chapter 4, Visio Formulas. For a detailed discussion of the arrow shape example, see Controlling How Shapes Stretch and Shrink in Chapter 5, Controlling Shape Geometry with Formulas.