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!?
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
if IN[0]:
TransactionManager.Instance.EnsureInTransaction(doc)
unit = doc.GetUnits()
format = FormatOptions(DisplayUnitType.DUT_METERS)
unit.SetFormatOptions(UnitType.UT_Length,format)
doc.SetUnits(unit)
TransactionManager.Instance.TransactionTaskDone()
OUT = "length unit changed to meter"
else:
OUT = "Set IN[0] to true!"
Could you try to replace this line: format = FormatOptions(DisplayUnitType.DUT_METERS)
with format = FormatOptions(DisplayUnitType.DUT_METERS,0.001)
and let us know if it works for you?
@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)
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