How to convert numbers into dimensions in PropertyWizard for Revit

When you have a Number value but need an Area, how do you do the conversion?

If you try to push the Number into an Area parameter, you will get a Type Mismatch error, saying ‘Target property is an Area parameter, but your formula returns a Double’:

PropertyWizard Result Check dialog showing a type mismatch error: 'Target property is an Area parameter, but your formula returns a Double.'

Similarly, if you try to push an Area into a Number, you will get an Invalid Cast error, saying ‘Invalid cast to Double’ :

PropertyWizard Result Check dialog showing an error: 'Invalid cast to Double'

‘Double’ is Revit-API-speak for a Number data type. The data types article lists the data types that are compatible with each parameter type, so you can avoid this kind of error.

Fixing the problem is simple: convert your result into the correct data type by multiplying or dividing by a unit of area.

To convert from a Number to an Area, just multiply by one unit of area. So if your number represents the number of square feet, multiply it by 1 sq ft:

PropertyWizard Formula window showing a formula for the category 'Walls', Target Property is 'DWD_Test_Area' and the Formula text is '23.6 * 1 sq ft'

Similarly, to convert from an Area to a Number, divide by one unit of area. So if you want to know how many square metres there are in a particular area value, divide it by 1 sq m:

PropertyWizard Formula window showing a formula for the category 'Walls', Target Property is 'DWD_Test_Number' and the Formula text is 'Area / 1 sq m'

Values from the Revit API

Dimension values from the Revit API don’t have units – they are not stored as Lengths, Areas, etc., just as simple Numbers, So you usually need to convert them when you use them in a formula.

For example, the X, Y and Z components of a location point are just numbers. To convert them into distances or lengths, you need to multiply them by Revit’s base unit for length, which is 1 ft:

PropertyWizard Formula window showing a formula for the category 'Columns', Target Property is 'DWD_Test_Length' and the Formula text is 'Location.Point.X * 1 ft'

Each type of dimension has a base unit. These are the ones that are relevant for PropertyWizard:

Data TypeBase Unit
LengthFoot
AreaSquare Foot
VolumeCubic Foot
AngleRadian

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.