The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Using Visio Shapes to Create Solutions

A Microsoft® Visio® solution almost always involves shapes. Visio offers the solution developer easy access to sophisticated graphics functionality with its drawing tools, and shapes can be programmed by means of formulas in the ShapeSheet® window.

Every Visio shape includes an assortment of formulas that represent its attributes, such as its width and height, and its behavior, such as what the shape does when a user double-clicks it. Because Visio shapes are programmable through formulas, you can make them behave like the objects they represent in the real world. So, for example, you can associate important data—part numbers, names, manufacturers—with shapes representing office equipment. Your shapes can then become powerful components whose unique behavior within a larger solution is provided by the formulas you write.

In this section...

Assembling Objects into Drawings

Shapes as Components

Assembling Objects into Drawings

If you're accustomed to thinking about graphics as a collection of vectors, you can think about Visio graphics in a whole new way. Visio shapes are parametric. That is, a Visio shape can adjust its geometry and other attributes according to the values of certain parameters—some defined by the Visio engine, others by the shape developer. Instead of fixed geometry based on hard-coded x,y coordinates, a shape's geometry is based on formulas that recalculate dynamically as a user manipulates the shape. Instead of drafting with lines, you assemble intelligent objects to create the drawing you want.

Visio shapes are parametric

Visio shapes are parametric.

  1. Head diameter
  1. Bolt length
  1. Thread length
  1. Bolt diameter
  1. Head thickness

In the previous bolt shape, the bolt length, thread length, and bolt diameter are parameters that are controlled by formulas. The head diameter and head thickness are derived from these parameters.

These parameters are independent of each other, within practical physical limits. The user could set them by dragging the selection handles to change the bolt length or bolt diameter, or by dragging the control handle to change the thread length. A program could set them with numerical data from a manufacturer's database of available sizes. TOP

Shapes as Components

Just as a procedure in a program encapsulates functionality so that it is easier to use and reuse, Visio shapes encapsulate behavior on the drawing page. Think of a Visio shape as a component whose default behavior is provided by the Visio engine, and whose unique behavior is provided by the formulas you write.

A solution rarely consists of a single shape. More often you'll develop a suite of shapes that support a particular kind of drawing, and you'll assemble these shapes as masters in a Visio stencil. A master appears as a shape in a stencil that you use to create instances, or shapes, based on the master. A master can be made of a single shape, multiple shapes, or a group. Instances inherit many of their characteristics from the master.

Users (or your programs) can drag masters from the stencil and drop them onto a Visio drawing. The stencil makes your custom shapes easy to reuse—the same shapes can be used by an engineer to simulate a product configuration, by a salesperson to show customers what they're buying, or by a graphic artist to create a catalog of your product line.

The first time a user drops a master onto a drawing page, Visio automatically creates an instance of the master on the drawing page and adds a copy of that master, or document master, to the drawing's document stencil. The document stencil is stored in the drawing file itself, which provides two major benefits:

  • The drawing is entirely self-contained and portable. Once the user creates the drawing, they no longer need your stencil.
  • Instances of a master inherit attributes from the master in the document stencil. A user can edit the master in the document stencil to change characteristics of all its instances in the drawing.

Because each instance of a master inherits from the document master, the instance can support a lot of complex behavior while remaining relatively small. Any formula can be overridden at the instance level, but global changes can be propagated to instances by altering the document master. And the drawing is portable because it contains copies of masters—the stencil or stencils that originally provided the masters are no longer required. All that's needed to view the drawing is a copy of Visio.

For example, the following network equipment shapes are designed to align and connect with the equipment rack shapes, so a network designer can create an accurate model of a server room. Individual shapes match the manufacturer's specifications for a precise fit, and the shape designer customized the shapes' alignment boxes and added connection points to make the shapes easier to use.

Network equipment shapes align and connect with equipment rack shapes

Network equipment shapes align and connect with equipment rack shapes.

To help the user create a drawing with your masters, you'll often provide a template. A template can provide shapes already on the drawing page, but more importantly, it can set up the drawing page with a uniform grid and scale, and include specific styles and layers. A template can also open one or more stencils. When the user creates a drawing based on a template, Visio opens the stencils and creates a new drawing file, copying the template's styles and other properties to the new file. As with the stencil, once the user creates the drawing, the template is no longer needed.

For details about the basics of creating Visio shapes, see Chapter 2, Creating Visio Shapes. For details about gathering shapes into stencils and providing templates with a solution, see Chapter 3, Visio Masters, Stencils, Templates, and Documents.