This post will be a little experiment to try out file attachments on the blog.
When customers send files to us, we often want to get a general understanding about the drawing contents. This is common in scenarios where customers are concerned about performance or file size. Visio drawings may be carrying some excess baggage along.
In addition to shapes on the page, a Visio document contains information about master shapes, styles, layers, fonts, colors, data and other items. These collections of information are used to accurately present the shapes on the page. However, they do not automatically get purged when shapes are deleted from the diagram.
Take the simple example of a flowchart. If you drag a Process shape onto the drawing page, Visio adds a copy of the Process master shape to the document and places an instance of this master shape on the page. If you delete the Process shape from the page, the master shape remains. Over time unused master shapes pile up. Normally this is no big deal, but some shapes contain large bitmaps or other complex information that will quickly increase file size.
Before you go out and delete every master shape from your document, keep in mind that master shapes are highly efficient when they are actually used in the drawing. If you took a drawing with many copies of the same shapes and then deleted the master, you would find the resulting document much larger and slower.
The attached DrawingAnalyzer.vsd document is a handy little tool written in VBA for counting the shapes in a drawing and determining whether there are unused master shapes. Also the tool counts shapes on the page with no master shape, and it keeps track of the level of grouping among shapes. More nested groups mean much slower performance.
To use the tool, open the file in Visio along with any other document you want to analyze. Make sure the document to be analyzed is in the active window. Then go to Tools > Macro > DrawingAnalyzer > ThisDocument > GetDrawingStats. Then open the VBA Editor (Alt+F11) and look in the Immediate Window (Ctrl+G) at the output. Here's a sample result:
Total Pages: 3
Total Shapes: 495
Top Level Shapes: 11
Group Shapes: 92
Max Nesting Depth: 3
Total Masters: 13
Unused Masters: 0
Shapes w/o Masters: 36
Total Patterns: 0
Unused Patterns: 0
Total Styles: 9
A top level shape is a shape directly on the page. All other shapes are found inside of groups. In this example, there are only 11 shapes spread across the 3 pages in the drawing. However, the total number of shapes is 495, meaning there are lots of shapes inside groups. There are even groups inside groups inside groups as evidenced by the maximum nesting depth of 3. This is not terribly efficient. All 13 master shapes in the document are used in the drawing, so that is good. 36 shapes have no master. If any of these shapes are similar, it would be more efficient to create a master shape for them.
The DrawingAnalyzer.vsd file is saved in Visio 2000/2002 format. Please post a comment if you have difficulties getting the file. As we said, this is a test.