As of API 2022, I was able to implement it as follows. But I couldn’t put the rounding.
Something related to FormatOptions.Accuracy.
Anyone know how to implement it?
Sorry for the translation.
Thanks
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(UnitTypeId.Centimeters)
unit.SetFormatOptions(SpecTypeId.Length,format)
doc.SetUnits(unit)
TransactionManager.Instance.TransactionTaskDone()
OUT = "length unit changed to centimeters"
else:
OUT = "Set IN[0] to true!"