Home » ShapeSheet

Casting Units in Visio’s ShapeSheet

Submitted by on October 3, 2006 – 11:50 pm | | 34906 views 4 Comments

« »

Read Full ArticleIf you work with different systems of units, you may have a need to convert ShapeSheet values to different units, without changing values. But when you Show Values in the ShapeSheet how can you specify exactly which units to use?

As an american ex-pat living in Munich, I personally run across this quite often. For instance I will be working in a metric drawing that uses millimeters for units, and I need to know a ShapeSheet value in inches.

There are a couple of reasons for this:

  • I’m American. I simply understand inches better. (Stop laughing rest-of-world, and thanks a lot, Britannia!)
  • Internal units. When you program against Visio, it’s convenient to use Visio internal units for numeric values. Internal units in Visio means inches.

To illustrate internal units, let’s look at a line of VB code:

visShp.CellsU(“Width”).ResultIU = 3.5

This sets the shape’s Width cell to 3.5 inches. Notice that we didn’t have to specify any units. That’s internal units! To set a value in units other than inches requires a more complicated line:

visShp.CellsU(“Width”).Result( Visio.VisUnitCodes.visMillimeters ) = 100

Let’s get back to the ShapeSheet. The simple trick to “cast” a value in the ShapeSheet is to add 0 units to the left of the value or formula.

Casting Units

In the illustration above, the Visio Guy shape displays his width value. He is 1-inch wide. The Guy on the right is also 1-inch wide, but has had his width formula altered:

Shape Transform.Width = 0mm + 1in

The 0mm on the left effectively casts the value to millimeters. The evaluation works from left-to-right, so 1in + 0mm will give you inch-values.

Casting Formulas in the ShapeSheet?

There are a few Visio ShapeSheet functions related to casting and unit-conversion, but deal only with angular quantities.

ANG360( angle_value ) Normalizes angle_value to between 0 and 360 degrees. The units of angle_value are returned, or the result is in radians if no units are specified.

DEG( radian_value ) Converts radian values to degrees.

FORMAT( expression, “formatpicture” ) Formats a value or formula using the format picture. You might have seen format pictures such as “0.00”, “0.##”, etc. that control the number of decimal places and the type of units to display.

FORMATEX( expression, “format”, [srcUnit], [dstUnit], [langID], [calID] ) Converts a unitless number from one unit system to another, and formats it. For our metric Visio Guy, we would have: Width = FORMATEX( 1, “0.00u”, “in”, “mm” ) This means: “take 1 as an inch-value, convert it to mm, and show me the result to two decimal places.”

PI( ) 3.1415926535898

RAD( degree_value ) Converts degree values to radians.


  • Cory says:

    Hi Chris at all,

    In your example it seems that Visio appears to be off by a factor 10. Since 1 inch equals to 2.54 mm, the 1-inch wide smiley should show it’s width as 2.54mm!

    According to some people, being American it’s understandable you don’t get the metric system as there is more in the world outside that Americans don’t get…
    Seriously: having lived in Canada I got to deal with both systems, and still find the metric system far superior as there is only one basic factor: 10. The imperial systems uses 2 (for fractions: 1/2″, 1/4″, …), 3 (3 feet in a yard) and 12 (12″ in a foot) and -nowadays?- sometimes 10 in systems that require 100’s or 1000’s fractions precision. How cumbersome, and that’s only a fraction of the problem for it get’s much harder when going 3D!

  • Visio Guy says:

    Hi Cory,

    1 inch = 25.44 mm
    1 inch = 2.54 cm

    U-S-A, U-S-A, U-S-A!

    I find that when drawing, arranging and spacing objects, and working with my hands that inches and feet are easier to work with. A foot can easily be divided by 2, 3, 4 and 6. With metric quantities, you get only 2 and 5, which can be weird and frustrating.

    Where the metric system shines is in eliminating calculation errors, and physical quantities like force, weight, etc. All engineers in the U.S. work primarily with the metric system, and students moan when they have to do calculations in feet, pounds and slugs.

  • Cory says:

    *blush* Reading can be hard at times… :/ My apologies!!

    Well, it probably comes down to a sort of “mother tongue” thing. I’m not grown up nor well used to the imperial system; basic math wasn’t too hard, but once I got to do the more advanced stuff like dividing with fractions (3/4th divided by 4), areas (I briefly worked for a fencing operation: fence off 1/3rd of an acre) and even volume (pour concrete for posts) I really needed pencil & paper!
    With decimals it’s so much easier (I find!): simply shift the comma and -indeed- 2 is your base factor.
    And I have to admit: I know many tricks for decimal math, and have no clue if any exist for imperial.

  • Visio Guy says:

    Hi Cory,

    I like the metric-imperial discussion. I am always fascinated that, although I went to Engineering School, I am nevertheless reluctant to totally abandon the imperial system, even though it seems at times to be unwieldy, and even completely whack-o.

    It seems to me that computers might actually enable it to survive, because they computers remove calculation difficulties. It parallels what is happening with languages. At one time, it might have looked like the internet would become an “English only” domain, or at least “Latin alphabet only”.

    But increasing speed and power, plus innovative software have enabled obscure dialects to survive, and complicated writing systems to become very usable. Think about typing Chinese or Japanese on an old typewriter…on a computer, it is pretty darn easy!

    Anyway, thanks for reading and participating! (and fostering U-S-A chest pounding…)

    – Chris

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code lang=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" extra="">

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.