Dynamo 0.6.3 now includes units—lengths, areas, and volumes—in addition to the more traditional, naked numbers. Here’s what you need to know.
Dynamo units vs. Revit units
Some Revit users may know that Revit’s internal units are imperial. Revit was originally developed in the United States, where we are still quite fond of our feet, cubic yards, and slugs (look it up! that’s what Americans measure mass in!). But the world is a smaller place now, and Revit has long since grown to accommodate users of metric.
A user sets the project units for Revit in the manage tab. This setting determines how all units will appear in Revit.
Dynamo units are specific to Dynamo, and a user is allowed to make them different from the units settings in the associated Revit file. Dynamo display units live in the Settings menu.
Set each unit system according to your needs and remember that units translate automatically. For example, if lengths in my Revit project are displayed in feet and lengths in my Dynamo graph are displayed in meters, then two chair elements placed 1 meter apart in my Dynamo file will be 3.281 feet apart in the Revit notation.
Units Math
The math nodes are smarter than they used to be. Now then can operate on units too.
Say I want to find out how much concrete I need for a 80 sq ft patio, 4″ thick. The Multiply node with tell you 26.667 ft3.
Real things, at least in the building industry, come in spatial dimensions of lengths, areas, and volumes, so if you try to multiply two volumes, the multiply node will complain. If you want to explore the 26-dimensional space of some string theories, you’ll have to find another visual scripting platform.
But what if you want to add 5 + 3 m? Your algebra teacher might yell at you, but the Dynamo team generally feels that what you do in your own time is your own business. You have a choice—unit-less numbers are often used as lengths, so when there is a units mismatch for Add, Subtract, or Modulo, Dynamo will take the type of the first argument and proceed as if that’s what you meant.
In other words, 5 + 3 m = 8 while 5 m + 3 = 8 m.
Numbers ? Units
There are a few ways that a number can acquire a unit, and a few more ways for a unit to be stripped away. The easiest way to make a length, area, or volume is to just make it. Use a Length, Area, or Volume node (Core/Input/…), or use a “Length from Number” node or its kin to give a number a physical meaning.
The Formula node does not handle units. Dynamo uses the amazingly powerful string-to-formula recognition capabilities of NCalc, which converts your equation into a usable Dynamo node. (Great blog post about the Formula node here.) The Formula node will take your length, area, or volume at face value. Both 3 and 3 cm will be treated simply as “3.” This, incidentally, turns out to be the best way to grab the number from the unit, should you so choose. The formula node’s output is unit-less.
XYZ nodes associate a distance unit with your data by default. If you are explicit about how you make your XYZs, using length nodes as inputs, you’ll get what you expect. But in the absence of information about the units, Dynamo will assume that you mean the internal unit structure of Revit, which is decimal feet. Is it too late to make a joke about blaming the British?
Similarly, when you unitize an XYZ, interpreting the XYZ as a vector whose length you would like to make equal to 1, its total length will be converted to 1 foot = 0.3048 m = 30.48 cm = 12 inches, etc.
Watch this!
The almighty Watch node is like none other, and visual scripting might be impossible without it. Now with units, a quantity has two things you might want to see: (1) the number with its display unit and (2) the “raw data,” which is how Dynamo stores the data internally. To toggle between seeing raw data and units, if appropriate, right click on the Watch node and check or un-check “Show Raw Data.”