Copying a Visio graphic as a metafile can improve performance

Post to Twitter

Visio has the capability of creating almost photo-realistic graphics with as much detail as you want.  However, the more detail (i.e. lines, gradient color fills, shading, etc.) in a shape, the more sluggish it will be when you move it around a page or drop it from a stencil.  One key reason for this is also one of Visio’s most powerful features… the ShapeSheet.  Every geometric element, such as a line or polygon, has a calculation engine behind it known as the ShapeSheet.  Each time you move a shape, the cells in all of those ShapeSheets are recalculating to account for the new position of the object.  More geometry (detail) in a shape means more recalculations.  At some level of detail the calculations become noticeable in the form of “latency” or sluggishness.

This can become a real problem when working with network equipment shapes.  For example, Visimation clients including Cisco, Juniper, Leviton, Alcatel-Lucent and others like the look of the very detailed shapes we produce for them.  However, if we delivered the shapes as Visio geometry their users would not be pleased.  That’s why we convert the shapes to “metafile” images.  A metafile is a single Visio shape with a single ShapeSheet.  It’s still a “vector” image which means that it will remain crisp and clear no matter how large or small you resize it.  You cannot edit this image like you can edit Visio geometry but in many cases, as with network equipment, you don’t want users to edit them anyway.  With metafiles, you can make the shape as detailed as you want such as in the example below that shows a photograph and the corresponding Visio shape:

Juniper Netwroks IC6000 Photo

Juniper Networks IC6000 Photo

Juniper Networks model IC6000 in Visio

Juniper Networks model IC6000 in Visio

So how do you create a metafile shape?  Although it takes some experience with Visio drawing tools to create an image like the above, making the metafile is quite simple… draw your shape, select Edit > Copy and then use Edit > Paste Special >Enhanced Metafile.  This will place a metafile copy of the shape on your drawing page.  You can then move it to a stencil if you want to reuse it with other drawings.  Note that the metafile copy will not be the same size as your original.  This is a quirk (bug?) in Visio that has existed since Visio 2003 but you can compensate for it by locking the aspect ratio (the vertical to horizontal ratio) of the metafile copy and then resizing its width to match the original.  Here are the steps:

  1. Select the copied metafile
  2. Select Format>Protection and check Aspect Ratio
  3. Open Size & Position Window (View > Size and Position Window)
  4. Select original graphic
  5. Copy the width value of the original from the Size and Position Window
  6. Select the metafile copy
  7. Paste into the width field in the Size and Postion Window of the metafile

In summary, if you need to draw very detailed shapes, this is the best way to optimize their performance so that they don’t act sluggishly when you drop or move them.

© 2009 – 2010, Visimation. All rights reserved.

Post to Twitter

9 comments to Copying a Visio graphic as a metafile can improve performance

  • Geministar

    Love this tip, really answered a big question I’ve had for a long time. When creating my own stencils, I’ve always struggled with how to maintain proper scaling, especially with text size when scaling/resizing very small…awesome!

    But, I’ve run into three problems with metafiles in Visio Pro 2003 (at work, so I can’t control version);
    1. Some tiny shapes have been misaligned, and since it’s a metafile, I can’t ‘fix’ the problem. I had to resort to remove the small items, add them back later after I’ve made the stencil a metafile and then group them.
    2. Making a 1D connector (following your other excellent tip on making a Format –> Behavior –> Line(1-dimensional) seems to be no longer possible. So, how can I utilize metafiles with snapping my networking/computing gear into a rack?
    3. My connection points disappear when I convert a stencil into a metafile. I don’t mind remaking them, but I was just wondering is there a way to convert them automatically?

  • I don’t understand your #1 point so I’m going to respond only to 2 and 3… please explain 1 if you would like me to try to help.
    2. BTW, in Visio language, you want to make a 1D shape, not a “1D connector”. I don’t mean to nit pick, but a connector is an entirely different type of object in Visio that we’re not discussing here so I don’t want to confuse things. Setting a shape for 1D behavior is still supported. The problem you identified is that Visio won’t set a metafile as a 1D shape. The way around this is to “group” the shape. So, just select your metafile, right click and select Shape>Group. Now you have a group with just the metafile in it and if you go to Format>Behavior you will see that the 1D interaction style is now available.

    It sounds like you read this article, but if not please do because it describes how to set the 1D endpoints of the shape so that it will fit into a rack:
    http://visiozone.com/?p=298
    Essentially, you’ll be setting the endpoints 19″ apart and down at the lower left and right corners of your shape. So, if you are using a rack shape that is properly designed, like the ones in Visio, or the ones we create for several manufacturers, your shape should fit in nicely.

    3. Connection points don’t paste when you copy a file and Paste Special as a metafile… you need to insert those connection points on the metafile itself. We have our own automation program that will convert a Visio drawing to a metafile, scale it, and place the connection points where they should be… but it’s not for public consumption ;-).

    I hope this helps.

  • Geministar

    Absolutely helps, and I ended up finding the solution to #2 on my own trying to work around the metafile limitation of not being recognized as a 1D *shape* (thanks for the correction), by adding another object and then grouping and setting to 1D, but I didn’t think of grouping a single shape…

    Regarding #1; specifically, I had tiny link lights on a RJ-45 port (speed and activity lights) for a custom switch stencil I had created. When I went to paste as a metafile, the ‘lights’ were misaligned, ruining the shape. I ended up removing them, saving as a metafile, adding the small lights back, grouping, converting to a 1D shape, and applying the endpoints.

    Thank you for the response and an excellent tutorial. Here I was thinking I knew a lot about Visio (I’ve used since before MS’s purchase) and a couple of your tutorials here really helped me.

  • This is what I suggest:
    Draw everything you want in Visio including any additional ports like the one you described.
    Group it all together
    Copy the group
    Paste as metafile
    Then do what we’ve discussed regarding 1D shape behavior
    I’d be surprised if anthing became jumbled up with the above process. You may find unexpected results if you are combining geometry with metafiles and then making a metafile of that combo. That may be what you did.
    NOTE: When you paste as a metafile, the copy does not have the same dimensions as the original. It’s a strange Visio thing. You’ll need to resize it to the height and width of the original. I suggest you set the aspect ratio proteciton on for the metafile, or grouped metafile, then set the width to the original width of your drawing.

  • Geministar

    I don’t know what settings I’ve might have changed, but now all of my shapes that I save as metafiles have begun to have a small ‘buffer’ area around them as the outline of the shape. Thus, when I apply a 1D shape to the metafile, the endpoints are offset by a small amount. Any idea how to fix that?

  • I’m afraid you won’t like the answer. That little “buffer” area around the shapes is another strange Visio artifact. To get rid of it, you need to:
    1. Resize your group that contains the metafile to the proper width
    2. Go to the ShapeSheet for the metafile that’s inside the group
    3. Tweak the Width and Height cells with formulas something like these:
    Sheet.xx!Width*1.055, Sheet.xx!Height*1.17
    …where “Sheet.xx” is the ID of the group that Visio has assigned. What you are doing is increasing the image size within the group. That’s why the group needs to be the size you want.

    You’ll notice that the default setting is “Sheet.xx!Width*1”. There’s no easy way to decide what that tweaked value will be. Our shape production program does that math automatically and a programmer much smarter than me figured out how to do that for whatever size geometry is in the drawing.

  • SveT

    Is there a possibility that you share a bit more on the topic how this “little buffer” is fixed?

  • We developed a shape production automation program and the buffer fix is embedded within that code. Unfortunately, we can’t comment on that exact code and how it does the job because it’s beyond the technical scope of this blog.

  • […] some time googling and trying to find an answer. Finally I ended up reading post titled “Copying a Visio graphic as a metafile can improve performance” by a professional Visio shape developer company called Visimation. In their post they […]

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>