Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Units of Global parameter value

Anonymous

Units of Global parameter value

Anonymous
Not applicable

Hi!

I'm trying to modify global parameters through Revit API (with Python scripts in Dynamo to be more exact). The API calls all work alright, but for some reason the GlobalParameter.GetValue().Value seems to return values in inches regardless of the units set in the doument. The document units are in mm and the the Global Parameters dialog in Revit also reports the parameters in mm. If I get the value from the parameter it returns it in inches (divided by 304.8) and when I set the value it also interprets it as inches.

 

Why is that? Is it a bug or a feature?

 

Regards,

Taavi

0 Likes
Reply
Accepted solutions (1)
1,967 Views
4 Replies
Replies (4)

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Taavi,

 

That is absolutely the expected behaviour.

 

The internal Revit database length unit is and always will be feet. That cannot be changed:

 

http://thebuildingcoder.typepad.com/blog/2011/03/internal-imperial-units.html

 

What you see in the user interface is just a view, and you can control what you would like to see in your view.

 

Similarly, your add-in or Python script has to retrieve the internal database values in feet and convert them to the desired view.

 

I hope this clarifies.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Anonymous
Not applicable

 

That explains things.

 

Thanks!

0 Likes

Anonymous
Not applicable

For further reference, since I couldn't find any good explanations how to convert the internal value to project units and vice versa, I found this way through the Revit API:

 

gp_type = GlobalParameter.GetDefinition().UnitType

display_units = doc.GetUnits().GetFormatOptions(gp_type).DisplayUnits

 

gp_type returns the UnitType of this global parameter (lenght, area, volume etc.)

display_units returns the DisplayUnitType to which Revit converts the internal value for displaying in the user interface.

 

Then I could use the UnitUtils class to convert between internal and project value (display_unit), irrespective of which unit the user has set in the project units dialog and which UnitType the global parameter has.

Anonymous
Not applicable

Totally unrelated but can anybody help me in reducing the digits of the fraction for my pipe sloping 0'-1 256/256" is a little difficult to use setting sleeves and hitting center lines when rotating the fittings and dropping from a horizontal branch into the building drain.

 

Please and Thank you.

 

Gus

0 Likes