When programming in Visio it is important to realize that many Visio objects have more than one name. Objects such as Pages, Masters, Cells and others have a local name and a universal name. Why two names? To address the problems that arise when combining the needs of localization (translating strings into multiple languages) with the needs of solution development (having a constant way to refer to things).
The local name is a friendly name that is displayed in the Visio user interface. For Visio’s own content, this is a string translated for the product sku of Visio (i.e. German strings in German Visio). Users have the ability to rename Page and Master and Cell objects, and that changes the local name. Local names allow users to see things in a language that makes sense to them.
The universal name is hidden from the user interface and can only be updated through automation. This keeps a universal name consistent across product versions and user edits. A constant name allows solution developers to refer to objects by an identifier that makes sense to them. This identifier works no matter what is displayed for the local name.
When working with Visio objects, developers should always use universal names to reference their objects. This advice applies to more than names. A number of properties and methods in the Visio API have universal syntax equivalents. If you find a property and notice the same property exists but ending in a ‘U’, use the universal property. A classic example is to use the FormulaU property to get and set formulas instead of Formula.
There is one special case where setting the local name of an object will automatically update the universal name to match. When the name of an object is changed the first time, both the Name and NameU properties are set to the new name. All subsequent changes to Name do not affect the NameU property. The sample code below illustrates this behavior.
Public Sub NameUDemo()
'Create a new master shape
Dim vsoMaster As Visio.Master
Set vsoMaster = ActiveDocument.Masters.Add
'Check the default Name and NameU property
Debug.Print "Initial Name/NameU:", vsoMaster.Name, vsoMaster.NameU
'Set the name of the master for the first time
vsoMaster.Name = "Apple"
'Check the current Name and NameU property
Debug.Print "Current Name/NameU:", vsoMaster.Name, vsoMaster.NameU
'Set the name of the master for the second time
vsoMaster.Name = "Banana"
Initial Name/NameU: Master.0 Master.0
Current Name/NameU: Apple Apple
Current Name/NameU: Banana Apple
While Visio began mainly as a diagramming package for business, the product has always been capable of making technical drawings. Visio supports measured and scaled drawings. It has features such as layers, guides and dimensions to help users create complex and precise drawings. Not surprisingly then, some of the earliest adopters of Visio were engineers and technical drawers. This group loved the combination of power and simplicity that Visio provides.
In the engineering software marketplace, one of the most ubiquitous applications is Autodesk’s AutoCAD. Because AutoCAD is so broadly used, it was essential for Visio to offer the ability to work with AutoCAD drawings. By integrating with CAD software, Visio connects into engineering and design processes, and it extends technical drawing to people in the organization that either don’t have the training to use CAD software or don’t have the resources to afford CAD software.
Before describing the CAD integration features in Visio, we need to point out which CAD drawings Visio can work with. Visio 2003 can work with DWG and DXF files saved in the AutoCAD 2000 format (R15) or earlier. Users working with newer versions of AutoCAD must be sure to save their drawings in a format that Visio will read.
The basic CAD integration features in Visio are import, conversion and export. Import is the ability to open or insert a CAD drawing into a Visio document and display the drawing on a Visio page. A drawing is opened using the File > Open menu command and changing the file type to AutoCAD drawing. A drawing is inserted using Insert > CAD Drawing from the menu.
The CAD drawing remains in its native form inside an ActiveX control, but users can choose the insertion scale and layer visibility for the drawing contents. These properties are accessed by right-clicking on the CAD drawing object and choosing CAD Drawing Object > Properties.
Conversion is the process where some or all of the contents of a CAD drawing are changed into Visio shapes and placed directly on the page. The conversion command is accessed by right-clicking on the CAD drawing object and choosing CAD Drawing Object > Convert.
Export is the ability to save a Visio drawing out as a CAD drawing. Visio shapes are converted to CAD entities, and any inserted CAD drawings are written back out as is. A drawing is exported using the File > Save As menu command and changing the file type to AutoCAD drawing.
Visio and AutoCAD use very different ways to describe a drawing. Thus translation between a Visio document and a CAD document is not perfect. There are many differences between Visio shapes and CAD entities such as with text or dimensions or fills / hatches. Also Visio shapes are large and complex while CAD entities are numerous and simple. It would be fairly common for a CAD drawing to contain 20,000 entities, but Visio does not normally handle 20,000 shapes at a time. Expect performance and memory issues if you convert such a drawing.
Because of the challenges converting between AutoCAD and Visio, the most common integration scenario is to import a CAD drawing into Visio but leave it in CAD form. Then you draw on top of the CAD entities using Visio shapes. Consider a floor plan imported from CAD that has Visio furniture shapes or electrical wiring drawn on top. If you want to save everything back to AutoCAD, there are some gotchas to be aware of. In order for Visio to correctly export both Visio shapes and CAD drawing entities, the CAD drawing must have been imported into Visio using File > Open (not Insert > CAD drawing). Opening a CAD drawing directly from a file causes Visio to properly set up the page scale and page origin to match the contents of the CAD drawing.
Visio has made improvements in its CAD integration feature set every release, but there are still some issues with Visio 2003 that make conversion and export problematic at times. Visio 2007 remedies many of these issues. If you work with CAD drawings, please tell us how you use them with Visio. If you are having trouble using Visio with your CAD drawings, we’d like to hear about that too. In a future post we’ll talk about some specific issues in Visio 2003 and changes in Visio 2007.
[All of the Visio blogs are making this announcement about the Visio Customer Council.]
We're always looking for ways to better understand the needs and concerns of Visio customers. To that end, one of the tools we use is the Visio Customer Council.
Council members are uniquely positioned to have their voices heard by the designers and developers of Visio. Members can provide feedback on proposed features and interact, face-to-face, with the Visio product team. Council members share their views in person, through regular conference calls, and in electronic mail.
There are a limited number of Council member positions, and members serve for a period of one year. We are recruiting for the 2006-2007 council now.
If you are interested in helping shape the next generation of Visio, we'll ask you to:
Since the readers of our blogs are among the most dedicated Visio users, we'd like to give you the opportunity to join the Council. If this sounds like something that would interest you, please contact us by e-mail, and we'll get our Planning group in touch with you.
Earlier this week we began creating a digital clock shape. In the previous post we used Visio’s shape operations feature to construct a digit shape for our clock. Today we will add a behavior to the digit to make it display any numeral required. Then we will complete the clock shape.
Our digit shape has seven geometry sections to represent the segments that make up the digit. We could make ten copies of our shape and delete the unneeded segments in each to make all ten numerals. However, our digital clock requires a single digit shape that is capable of displaying any numeral. A particular numeral is shown by showing and hiding the correct set of segments.
This special behavior will be defined using formulas we add to the Shapesheet of the digit shape. For those unfamiliar with the Shapesheet, here are the essential things to know to work with a shape:
A single User-defined cell named Digit is created to specify the current numeral to display in the shape. The NoShow cell in each geometry section is used to determine the visibility of the geometry. We enter formulas in each NoShow cell to return True or False depending on the value in User.Digit.
Each NoShow formula is a little different since it must control the visibility of a specific segment in the digit shape. The seven NoShow formulas are listed below. If you are building your own version of the digit shape, your geometry sections may be in a different order. Therefore you need to work out for yourself what formula goes where.
You can now test the digit shape by entering each of the 10 possible numerals in the User.Digit cell to verify that the correct geometry appears in each case. The digit has been transformed into a multi-shape – a single shape that can take on multiple appearances. Now we can use the digit shape to complete the clock.
The digital clock is composed of four digit shapes for the hours and minutes, plus a pair of dots separating the hour and minutes, plus a rectangle to group everything together. Four copies of the digit shape are arranged side by side. Then two small squares are drawn and formatted to match the digit shapes (using Format Painter). You can use the Combine command from the Shape > Operations menu to combine the two squares into one shape for efficiency. Then a rectangle is drawn around everything. The rectangle is moved behind the other shapes using Send to Back and given a thicker border with a slight corner rounding.
Next we need to assemble all the shapes into a group. Rather than selecting everything and grouping it, we will convert the rectangle shape into a group. This is more efficient because it takes advantage of the ability for group shapes to have their own geometry and text. The rectangle is selected and the Convert to Group command is chosen from the Shape > Grouping menu. With the rectangle still selected the other shapes are added to the selection using Shift+Click. The Add to Group command is chosen to make the digits and squares sub-shapes of the rectangle.
The group shape will keep track of the time to be displayed in the clock. It will break out the time into hours and minutes. Three User-defined cells are added to the group’s Shapesheet to track these values. The time is placed in the User.Time cell, which is set to the NOW() function for this example. This function returns the current date and time and will automatically refresh about every minute (or sooner if the user is taking other actions).
Each digit shape uses the hours and minutes information to determine what numeral to display. The User.Digit cell in each digit shape is given a special formula to extract the digit from the group’s hour or minute value. The formulas below are placed into the four User.Digit cells. The Sheet.ID in these formulas should be the Sheet.ID of the group shape. This is easily found by noticing what Sheet.ID is referenced by the formulas in the Shape Transform section of the digit shape.
First Hour Digit: INT(Sheet.14!User.Hour/10)
Second Hour Digit: MODULUS(Sheet.14!User.Hour,10)
First Minute Digit: INT(Sheet.14!User.Minute/10)
Second Minute Digit: MODULUS(Sheet.14!User.Minute,10)
This completes the digital clock! We created complex geometry using shape operations to make construction easy. Then we built a multi-shape with special behavior to selectively display the geometry. Finally the components were wrapped in a group to control the multi-shapes from a single input value. The clock in this example uses a total of six Visio shapes for the display. Using the techniques shown here though, it is possible for you to combine all the digits together with the squares into a single multi-shape – reducing the total shape count to two. We’ll explore this issue of minimizing shape count in a future post.
Shape design is somewhat of an art in Visio. There are so many things that go into creating professional-looking content that a certain level of expertise is required. One of the goals of the Visio Insights blog is to provide that expertise in an understandable format. Another goal is to demonstrate best practices to help you use Visio in the most effective manner. This week we will demonstrate shape construction techniques by creating a new shape from scratch.
Our example is a digital clock shape. The numerals in the clock – the digits – are drawn in geometry instead of text. This allows us to be more creative with the appearance of the digits. We want the digit to appear as it is shown in a Liquid Crystal Display.
Today’s post focuses on ways to use the power of Visio to create shape geometry. There are several approaches to constructing geometry. You can use Visio’s drawing tools to manually draw the lines and arcs needed for the shape. This works well for simple geometry, but the tools are not suitable for complex geometries. You can also build geometry using the Shapesheet window by entering the actual formulas in the Geometry sections. This approach is very precise but can be extremely slow and difficult to get things right. A third approach is to build a complex shape by assembling it from simpler pieces. This is the simplest approach because it makes Visio do the heavy lifting to create the final geometry.
Let’s construct a shape to represent a digit for our clock using this assembly approach. A digit is composed of seven individual polygons, which are shown or hidden to generate each possible numeral. These polygons have tiny gaps separating them. Also a slight rounding is applied for aesthetics. We start by drawing a rectangle 1/2 in. wide by 1 in. tall. Then we use the Offset command found in the Shape > Operations menu to create two additional rectangles 1/16 in. away from the original shape. The outermost rectangle is not needed, so it is deleted. We select the remaining two rectangles and use the Subtract command from the Shape > Operations menu to create a single shape with its middle removed.
The crossbar is added by drawing a rectangle 1/2 in. wide by 1/16 in. tall and positioning it in the center of the existing shape. A composite shape is created by selecting both shapes and choosing the Union command from Shape > Operations. Note that commands such as Union and Subtract destroy the selected shapes and generate a brand new shape with the composite geometry. For this reason, you should create the geometry of a shape before moving on to other aspects like formatting or behavior.
Next we need to segment the shape into seven pieces with small gaps in between. We draw lines in the places where we want the gaps to be located. The lines extend beyond the shape geometry to facilitate the next shape operation. Getting the lines in exactly the right place may require zooming in very close. Otherwise Visio’s snapping behavior may prevent you from placing your cursor where you want it. Once all the lines are drawn they need to be selected. This is accomplished by selected all the shapes and then Shift+clicking on the digit shape to deselect it. Then the Offset command is run with a spacing of 0.015 in.
The offset lines serve as break points where the underlying digit shape must be segmented. The segmenting is done using the Fragment command in Shape > Operations. This command uses all the selected geometry to define simple closed polygons. We can apply a green fill to the resulting shapes to better see them. The inside squares are deleted first. Then the tiny corner polygons are deleted, leaving only the seven segments for our digit.
We now have seven individual shapes that make up our digit. By selecting the shapes and choosing the Combine command in Shape > Operations, the seven shapes are converted into a single shape containing seven geometry sections. This is a much more compact representation of the digit - decreasing file size and improving performance. Corner rounding of 0.02 in is applied to the shape as a final touch.
While there were several steps to get to the end result, we never had to do any complicated drawing or Shapesheet formula entry to construct this shape. Two rectangles were drawn for the basic digit outline. Then eight lines were drawn to define break points for the segments. Visio’s shape operation commands did the rest of the work. In the next post, we’ll add some smarts to this digit shape and use it to build up our digital clock.
Every once in a while we hear from a user who has encountered a cryptic error message in Visio and is left helpless. Most of Visio’s error messages are somewhat explanatory, though we continue to improve their wording. However, there is another set of messages that report “internal errors”.
Internal errors are usually problems where the Visio program has done something wrong, whereas other errors are shown in response to things the user has done. Internal errors can be identified by an error number included within the message text. Often the message provides no clue as to the problem or possible remedies. We’ll look at one of the more frequently encountered internal error messages in this post – Error #318.
Error #318 can occur when you copy and paste a shape from one document to another. There are some specific circumstances needed to trigger the error:
This is not the only way to encounter this error, but it is representative of what can happen. Here are the steps to reproduce the problem:
The problem for Visio is the secondary reference in the Document Shapesheet to another cell. Normally when a shape moves between documents, Visio automatically copies over the page and document cells that the shape depends on – creating them if necessary. Visio sees that the shape being copied has a reference to cell User.Test1 in the Document Shapesheet, and it creates this cell in the target document. Visio does not know that the contents of cell User.Test1 themselves have a reference to another cell. Cell User.Test2 is not created in the target document. When Visio tries to complete the Paste operation and recalculates the cells, it finds that there is a missing reference. Error #318 is shown and the Paste operation fails.
Unfortunately this is no simple bug in Visio but a significant architectural limitation, which means that a fix for the problem is not forthcoming. However, by understanding how this error can occur we can identify some remedies. In order for the Paste operation to succeed, the target document must have the correct set of Document Shapesheet cells in place. It is certainly possible to add the required cells prior to doing the Paste. Another option is to make sure the shape has a direct reference to each of the Document Shapesheet cells itself. This might be a solution for shape and solution designers to use so that their users don’t experience strange Copy / Paste failures.
If you encounter internal Visio errors, please tell us about it. We’ll try to explain a few other common ones in a future post.
In a previous post, we mentioned that Visio 2003 introduced a shape rotation handle to quickly allow rotation of shapes. This eliminated the need to switch to a dedicated rotation tool. You can rotate a shape by selecting it and dragging the rotation handle around to a new position.
One of the more subtle behaviors of rotation is the way Visio snaps the shape to particular rotation angles. The degree of fine control over the rotation angle varies with the distance of the cursor from the shape. This means that dragging the rotation handle in a wide, sweeping arc lets you precisely control the angle of the shape. Dragging the rotation handle in a small, tight circle lets you rotate to just a few angular positions. The status bar provides feedback on the current angle and snap increment.
Visio defines snapping zones around each shape to determine what rotational snap angle to use. The farther your cursor is from the rotation pin, the smaller the snap angle will be. There is no need to try to keep your cursor directly on top of the rotation handle while you are rotating. The rotation handle and snap angles work for single shapes and selections of multiple shapes.
There is one additional feature related to the rotation handle. Once you place your cursor over the rotation handle, the Center of Rotation pin is displayed for the shape. This pin is usually in the center of the shape, and it designates the point that rotation revolves about. It is possible to drag this pin to a new position inside or outside the shape. Try it to see how this affects the way that the shape rotates. This is especially useful when multiple shapes are selected.
Visio has been around for over 15 years, and there have been many product versions released. One of the biggest issues that can impact users from release to release is a file format change. Changes in Visio's file format can be painful for customers because people must often share documents with others who are using a different version of the product. Let's look at this issue in depth.
Until recently Visio changed its file format with every major release. This change was not as painful for customers as it is today because most people exchanged drawings within a much smaller circle of users - usually others in the same department who would have the same version of Visio installed. As Visio gained more customers and those customers shared their drawings with other groups, version incompatibility became more commonplace.
Visio file format history
Default file format
Backward save format
Visio 4.0, Visio 4.1, Visio 4.5
Visio 5.0, Visio 5.0 Plus
Visio 2000, Visio 2002
Visio 2003, Visio 2007
Visio 2002 was the first major release to maintain the same file format as the previous release. Visio 2003 once again introduced a new file format. Visio 2007 will use the same format as Visio 2003. Every version of Visio is capable of reading all older files. Visio 2007 can open a Visio 1.0 document. Generally, each version of Visio is capable of writing back one file version as well. Thus Visio 2003 can save a file out in 6.0 format (readable by Visio 2000 and Visio 2002), but it cannot save out a 5.0 format or earlier. When saving to an older format, some features and information may be lost if the older Visio does not support those features.
Why change the file format? To add features and new capabilities. Visio 2000 introduced a new file format to allow vastly larger and more complex diagrams to be created. Internal limits on the number of shapes and other items were removed. The most recent change for Visio 2003 was required to introduce Unicode text throughout the application, though we took advantage of the change to build in some other great features as well.
Will the file format change again in the future? It might, but Visio must be mindful of the problems a change can cause for customers. Word, Excel and PowerPoint have a new file format in Office 2007. One of the things Microsoft is doing to make this transition go more smoothly is to release a compatibility update to Office 2000, XP and 2003. Those versions can then read and write the new format. Perhaps Visio should consider this approach.
In the meantime, how do you deal with file incompatibilities? The first option is to have the document author save the drawing as an older file version. A second option is for the document author to publish the drawing using the Save As Web Page feature. If you have received a document that was created in a newer version, you can also download the free Visio Viewer to at least view and print the document. File incompatibility can be frustrating, but hopefully you now know what versions of Visio work with each format.
Today is a holiday in the US, so we're republishing this topic from a newsgroup post not too long ago.
Summary: You can add the User.visEquivTitle cell to your shape and provide a string that will display as a tooltip in HTML web output. The shape must also have at least one custom property for the tooltip to be visible.
Steps: 1) Select the shape in your drawing that you want to add a web tooltip for 2) Go to Window > Show Shapesheet 3) Go to Insert > Section, check User-defined cells and click OK 4) In the newly created section, click on the row name User.Row_1 to select the title of the row 5) Type visEquivTitle and press Enter - you should now see User.visEquivTitle for the row 6) In the Value cell of that row, enter the text you want to display surrounded by quotes (e.g. "Hello World") 7) If you instead want to display the same tooltip as the Shape ScreenTip enter =Comment (no quotes) 8) Go to Insert > Section, check Custom properties and click OK 9) You can fill in the custom property Label and Value if you want this information to be visible 10) If you don't want the custom property to be visible, enter TRUE in the Invisible cell 11) Close the Shapesheet window and repeat for any other shape you like 12) Choose File > Save as Web Page to create the HTML output
As you can see this is a bit involved. The capability was designed more as a developer feature than an end user feature. We recommend tying the Shape ScreenTip to the User cell so that you see the same tooltip in both Visio and the web output. It should also be possible to use Macro Recorder to automate these steps. If your shape has a custom property but does not have the User.visEquivTitle cell, Visio will display the shape's text in a tooltip instead.