Sometimes your Visio SmartShapes can be like beauty pageant contestants: they just need to look good, but don’t need a lot of intelligence. The creators of Visio realized this (after five versions) and gave us a way to streamline lots of “dumb” vector data. The ShapeSheet function: POLYLINE and the geomettry row: PolyLineTo will help you get the job done.
The Problem: Too Many ShapeSheet Rows
We’ll start with a shape that has lots and lots of geometry rows. At right, you see an outline of Washington State. This is where your Starbucks Coffee, your Amazon Books, your Boeing Airplanes, your Microsoft Software, and, curiously your Apples come from!
The Washington shape has 4 geometry sections and a whopping 279 total geometry rows! That’s a lot of ShapeSheet cells. And in all of those cells there are exactly zero smart formulas. The formulas are simply proportions of the Width and Height of the shape. Nothing smart about them at all.
When you open the ShapeSheet, you immediately get a headache because of all the data you have to scroll through. Wouldn’t it be nice if we could somehow simplify this mess? Well there are a couple of solutions…
First Stop: Metafiles
One way to make this shape more efficient is to convert it to a meta file.You can do this by following these steps:
- Copy the shape with Ctrl + C
- Choose Edit > Paste Special
- Select: Picture or Picture (Enhanced Metafile) from the list in the dialog box.
The ShapeSheet behind your meta file shape will be vastly simplified, but it will also be a lot less flexible. You won’t be able to give the shape any line or fill formatting. The shape truly becomes a foreign object.
Enter PolyLineTo and PolyLine( )
If you examine the image above, you’ll see two oddities: a PolyLineTo row, and a POLYLINE function in the A column.
The POLYLINE ShapeSheet function essentially allows us to enter a string of x, y coordinates that define every vertex of a shape. That list can be very, very long, and will have to be to describe the geometries in our Washington shape! In the image above, the Geometry describes a rectangle, drawn clock-wise from the lower-left corner.
The POLYLINE function only makes sense to Visio if it is inserted into the A-column of a PolyLineTo geometry cell. Most geometry cells that you see are MoveTo or LineTo cells. The PolyLineTo row is simply another flavor of geometry-row.
It’s easy to convert a LineTo or other Geometry row to a PolyLineTo row. All you have to do is right-click a cell in the row, and choose Change Row Type from the menu. A dialog will pop-up, and you can choose PolyLineTo from the list.
The most efficient setup is to have a geometry section with two rows: the first being a MoveTo row, the second being a PolyLineTo row–just as the image above shows.
So let’s take a look at our rectangle, with the various Geometry-row bits written next to the respective vertices:
A couple of notes:
- Geometry1 and Geometry2 represent the same point. This is because the shape needs to close, so that it can have a fill. Closed geometry sections always “return home” at there last row.
- The first two arguments in the POLYLINE function describe the x- and y-types for the points. 0 indicates the points are proportions of width and height, respectively. 1 indicates that the points are local coordinates within the shape. If the points have no units, then they will be understood as Visio’s internal units, which are always inches. In our shape above, they’re both 0, so the following x,y pairs represent “width-times-a-proportion” and “height-times-a-proportion”.
What Do We Gain?
Despite the HUGE reduction in ShapeSheet rows, the file size gains are, rather modest–somewhere on the order of 10%. Visio probably does a good job of compressing all those dumb geometry rows in the non-polylin-ed shapes. Interestingly, the meta files can be quite a bit smaller in file size, but again, this is at the expense of being able to format the shape.
However, the actual performance of the shape is better with the polyline info. You’ll notice that the “live dynamics” of the shape are more fluid, and quicker to respond while you are resizing it.
Another interesting stuff is that your hard-earned POLYLINE stuff survives the Combine boolean operation. Fragment and Union, however tend to take you back to lots and lots of individual geometry rows.
How Do I Convert a Huge Shape to Polylines?
“So, Visio Guy, now that we know how to reduce complicated shapes to lists of points, how do we go about converting our shapes without tediously entering each point by hand?”
Glad you asked! Just download the custom Visio diagram that I’ve created. It contains VBA code that will automatically “polyline-ify” every geometry section in your selected shape. And don’t worry about messing up your shapes, the code creates a copy of the selected shape before it does any modifications!Visio Polyline Shape Maker (720 downloads)
Geek Notes on POLYLINE()
I’ve noticed that the POLYLINE function seems to do fairly sophisticated parsing. You can mix units and formulas in your list of points! I modified the formula from our rectangle above to:
POLYLINE( 0, 1, 0, Height*2, 1, 1, 1, 1mm )
Notice the mixing of formulas, constants, and different units! It functioned perfectly fine. So here, we have all the x-points being proportional to the width, all the y-points being absolute in inches, except the last point, which is 1mm, and the first point which is twice the height. Strange, but it works!
What I can’t say for sure is whether or not Microsoft recommends mixing formulas and units in the POLYLINE function.