Hi i was wondering if there is an easy way in Dynamo that changes Revit units from lets say milimeters to meters?
Every time i want to run my script in a new project i first have to change the units in Revit for it to work.
This will automatically set the project units to Meters with no input needed. Wish I could remember which post I got the code from to give kudos. Apologies to the creator.
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
TransactionManager.Instance.EnsureInTransaction(doc)
unit = doc.GetUnits()
format = FormatOptions(UnitTypeId.Meters)
unit.SetFormatOptions(SpecTypeId.Length, format)
doc.SetUnits(unit)
TransactionManager.Instance.TransactionTaskDone()
OUT = "Project units set to Meters"
4 Likes
Thank you very much!!