Setting Project Units - From Millimetres to Metres Automatically

Hey All,

I’m in the process of creating a portal frame ‘generator’ for a trial generative design through Robot - One slight issue I’m having is that my company Revit template is set in mm. For easiness within Dynamo, I’ve done this in metres, so I get the nice little grid! I don’t really want to have to keep changing Project Units each time. So I’m wondering whether this is possible through a python coding?

I’ve tried all node based parameter’s however I can’t seem to get Project Units. I’ve created the python coding from the topic below, but this only calls up the current project unit setting. Could anyone give me a hand with a code which automatically changes the project units to metres!?

[Project unit settings](https://forum.dynamobimDetect Units.dyn (1.3 KB)


1 Like

Hi Daniel!

You can do something like this:

import clr

from Autodesk.Revit.DB import *

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

if IN[0]:
	unit = doc.GetUnits()
	format = FormatOptions(DisplayUnitType.DUT_METERS)
	OUT = "length unit changed to meter"
	OUT = "Set IN[0] to true!"

unitToMeter.dyn (1.9 KB)


Thanks @Einar_Raknes!

Hi Guys,

I’m a total noobie to dynamo and know very little about python.

Was just wondering if it is possible to modify this script to leave at mm but set the decimal places of the length and angle to 3 decimal places?

I’d appreciate any help


Hello @hargreaves102

Could you try to replace this line:
format = FormatOptions(DisplayUnitType.DUT_METERS)
format = FormatOptions(DisplayUnitType.DUT_METERS,0.001)
and let us know if it works for you?


This worked great for the Length thank you very much Einar.

Is there a similar fix for changing the angle to 3 decimal places?

Take a look at the different unit types here:

And the Display Unit Types here:

I guess a combination of DisplayUnitType.DUT_DECIMAL_DEGREES and UnitType.UT_Angle would work. Give it a shot an let us know how it goes.


Again, your a lifesaver. This has worked perfectly.

Thanks for taking the time to help out, its appreciated!

How would I add other options to this? Options like UnitSymbolType and Suppress Trailing 0’s?

Did you end up figuring this part out?

@The_Minty For UnitSymbolType and in the case of millimeters, I added
UnitSymbolType.UST_MM. So, Line 16 of the above code from Einar_Raknes now looks like this:

format = FormatOptions(DisplayUnitType.DUT_MILLIMETERS,UnitSymbolType.UST_MM)

I also referenced this page for UnitSymbolType enumeration:


How to add to the script the modification of usedigitgrouping and digitgroupingsymbol?

2 posts were split to a new topic: Setting Project Units - set Accuracy

Hello, does anyone know how to add a precision of 0.001 on top of the changes you talk about?
I am trying:

format = FormatOptions(DisplayUnitType.DUT_METERS,0.001, UnitSymbolType.UST_M)

Notice this 0.001 in the middel but doesnt seem to work, I also need to add this precision change and I dont know where to put it or how to get it in the logic