Units of Measure in Visio Formulas

3 4

Microsoft Visio assigns the result of a formula differently depending on the cell in which you enter it:

  • In general, cells that represent shape position, a dimension, or an angle require a number-unit pair that consists of a number and the qualifying units needed to interpret the number. For example, a formula in the Width cell might evaluate to 5, which might mean 5 inches or 5 centimeters, depending on the units of measure in effect for the drawing.
  • Other cells have no intrinsic units of measure and evaluate to a string, to TRUE or FALSE, or to an index, depending on the nature of the cell. For example, the formula =5 in the FillForegnd cell means color 5 from the drawing's color palette, whereas =5 in the LockWidth cell means true (only zero is false ) and locks the shape's width.

For best results, always specify the units of measure in your formulas, rather than relying on Visio to supply the correct units. If you don't specify units of measure with a number, it is evaluated using the internal units defined for the cell, which can be page units, drawing units, type units, duration units, or angular units:

  • Page units measure sizes on the printed page, including typographic measurements. Page units are typically used for line thicknesses and font sizes that do not scale with the drawing.
  • Drawing units specify the real-world measurement, such as a 50-meter pool (drawing units) that appears 10 cm long (page units) on paper. For example, if you enter the formula =50 into the Width cell, which expects a number-unit pair in drawing units, Visio supplies the default drawing units currently set for the page and evaluates the formula accordingly.
  • Angular units measure angular distances, such as a shape's rotation. Angles can be expressed in degrees or radians.

Internally, Visio uses inches for measuring distance, radians for measuring angles, and days for measuring durations.

For more details on units of measure, search the ShapeSheet Reference in the Microsoft Visio Developer Reference (on the Help menu, click Developer Reference).

Multidimensional Units

A Visio formula that multiplies or divides dimensional units produces a result in multidimensional units that can be stored in some cells. For example, if a shape is 5 feet wide and 10 feet high in drawing units, the formula = Width * Height evaluates to 50 ft ^ 2 (50 square feet). The following cells can store multidimensional results:

  • The Value cell in a row of a Custom Property or User-Defined Cells section in the ShapeSheet.
  • The A, B, C, and D cells in a row in the Scratch section in the ShapeSheet.

Use the FORMAT function to display multidimensional units using abbreviations such as sq. in. For details, see the FORMAT function in the Microsoft Visio Developer Reference (on the Help menu, click Developer Reference).

Be aware that most multiplication is intended to combine a value that has units with a value that has none. If such a calculation happens to multiply two values with units, the multidimensional result might not make sense. For example, if a color cell such as FillForegnd is set to the product of two cells in the Geometry section, the result would be a #DIM error because cells in the Geometry section always have units but the FillForegnd cell cannot contain a multidimensional value.

Note


In versions of Visio earlier than Visio 2000, formulas that multiplied or divided dimensional values could generate incorrect results. For example, the formula =1 cm. * 1 cm. was converted to 0.394 in. * 0.394 in. Multiplying just the constants and not the units, this formula evaluated to 0.155 in. Converting this result back to centimeters by multiplying it by 2.54 cm./in. produced an incorrect result of 0.394 cm. instead of the correct result of 1 cm.^2 (centimeters squared). Existing solutions that employ workarounds for this behavior should be changed to take advantage of multidimensional units in Visio versions 2000 and later.

Specifying Units of Measure

Because many drawings represent physical objects, you can specify units of measure in the imperial and metric systems, and you can specify angles in radians, decimal degrees, or degrees, minutes, and seconds of arc. You can also use standard typographical measurements such as picas, points, ciceros, and didots.

For best results, always specify a unit of measure when you enter a formula in a cell that expects a dimensional value, as shown by the examples in the following table.

Examples of number-unit pairs

Use

Don't use

5 in.

5

Width + 0.5 in.

Width + 0.5

7 in. * 1.5

7 * 1.5

DEG(MODULUS(Angle, 360 deg.))

MODULUS(Angle, 360 deg.)

Specifying units explicitly makes it easier to identify the number-unit pairs in your calculations, so that you don't inadvertently divide one number-unit pair with another number-unit pair or combine incompatible units, such as adding angles to lengths. In addition, specifying units of measure makes it easier to localize your formulas for international use.

You can identify units using a variety of strings (such as i, in, in., inch, inches) and you can use the FORMAT function to display results using popular formatting options.

Note


If you're planning to localize your solution for international markets, you might want to use universal names in formulas. The local name is displayed to the user and must be translated if the solution is localized. The universal name is (for the most part) concealed from the user, does not need to be translated, and can be assigned only with Automation.

For more details about units of measure and a list of the units supported in Visio, search the ShapeSheet Reference in the Microsoft Visio Developer Reference (on the Help menu, click Developer Reference).



Developing Microsoft Visio Solutions 2001
Developing Microsoft Visio Solutions (Pro-Documentation)
ISBN: 0735613532
EAN: 2147483647
Year: 2004
Pages: 180

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net