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’:
Similarly, if you try to push an Area into a Number, you will get an Invalid Cast error, saying ‘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:
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:
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:
Each type of dimension has a base unit. These are the ones that are relevant for PropertyWizard:
Data Type | Base Unit |
Length | Foot |
Area | Square Foot |
Volume | Cubic Foot |
Angle | Radian |