![]() |
![]() ![]() |
|
Layering Visio Drawings
A CAD user describes his experiences in learning how to use layers in Visio. David Parker describes how to use layers to control diagram display. As a bonus, he includes two in-line VBA scripts that allow Visio to mimic layer features found in CAD software: insert layer name in drawing, and group layer controls. Coming from a CAD background, there were two areas of using Visio where I had to grasp new ways of working: Layers and Shared Drawings. The Purpose of Layers Visio has the ability to have a shape assigned to more than one layer -- a concept unknown in the world of CAD. This can be useful, for example, when your diagram has a Partition layer, and you want some shapes on the To Be Removed layer and some on the New Build layer. Remember that shapes can belong to no layer at all, so your Visio diagram can have no layers at all -- again, a concept unknown to the CAD user. It is not a good idea for drawings of any complexity to have no layers. The Layer Properties dialog box is Visio's primary interface to the properties of the layers.
Take a look at the # column: this gives you the count of shapes on the layer. In the figure, you see a 2 in each case. The Square, Triangle and Circle shapes are on layers One, Two, and Three respectively, while the Sigma shape is on all three layers (it gets counted on each layer). Moreover, if the shapes were groups (several shapes grouped together), then its sub-groups are counted, too. For this reason, do not rely on this count to be an inventory count.
The Layer Properties dialog box can be used to change the color of shapes. The figure above demonstrates how an assigned layer color changes the line and text color, but removes fill color. Fortunately, this is not permanent; clear the layer color to return the shapes' original settings. Notice that the Sigma shape has not changed appearance, even though it is assigned to layer Three, amongst others. This is because when Visio has a choice, so it does nothing. If, however, all its assigned layers had the same color, then Sigma would change, too. The Drawing Explorer in Visio 2000 offers a way of changing the visibility of a layer easily, and lets you set the active layer. The active layer, or layers, is applied to all subsequently drawn shapes.
The Legend Shape The Legend shape is a useful indicator of the status for each layer, essential information if you need to repeat a print of a drawing at different times. The Legend shape shows the visibility and printability of each layer, and is not assigned to any layer (for this reason, it appears under the Shapes branch of the Drawing Explorer, and not under the Layers branch). I have assigned a double-click event to the Legend shape, which allows text to be created automatically. To create this shape, just draw a rectangle, then show its ShapeSheet (from the Visio menu bar, select Window>Show Shapesheet). Scroll down to the Events section, and select the EventDblClick cell. In this cell, type (or copy'n paste) the following in-line VBA code (note that this is all one line): =RUNADDON("strL=""Layers on this page:"": Back in the drawing, double-click the shape to refresh the text. You can format the text, and use tabs to make it look pretty. Grouping Layers In the following example I have created two groups of layers, A and B. Group layer A contains layers One and Two, and group layer B contains layers One and Three. The sequence shows the effect of switching off group A (step 2), then switching on group B (step 3), and finally switching off group B (step 4). The Legend shape shows the status of the layers at each step.
The Group Layers Switch shape In practice, I find it easier to turn off all layers before turning on selected layers of a particular group. To automate this task, I created two shapes with some in-line VBA code that turn a group of layers on or off simultaneously. The in-line VBA code for both shapes is identical, except for one number to be changed. Like the Legend shape, just draw a rectangle, then show its ShapeSheet, and add the following code to the EventDblClick cell in the Events section. Again, this must be typed as a single line: =RUNADDON("intM=1: This statement turns off the layers. To turn on layers, change intM=0 to intM=1 . The more adventurous amongst you could make this value read from a custom property on the shape, rather than have two different shapes. Okay, so how does this work? Firstly, there is no error checking, so follow my instructions. All you have to do is type in a layer group description, then type each layer name you want to turn on/off preceded by a semi-colon. Each layer name must be type perfectly, or else you will get an error. The code assumes that there is a semi-colon separated list in the shapes text. It loops through each of them, ignoring the first item because it is the group description, then sets the layer visibility and printability to the 1 or 0, depending on what is the value of intM. So long
|
|
|
Copyright © 1998-2007 DBM & others | Disclaimer | Privacy | Re-publication | Trademarks | Webmaster | Home |