Describe the bug
DB.Units.SetFormatOptions() expects UnitType, but should also expect ForgeTypeId
To Reproduce
units = doc.GetUnits()
specs = units.GetModifiableSpecs()
target_spec = next(iter(x for x in specs if LabelUtils.GetLabelForSpec(x) == 'Length'))
target_options = units.GetFormatOptions(target_spec)
target_units = UnitUtils.GetValidUnits(target_spec)
target_unit = next(iter(x for x in target_units if LabelUtils.GetLabelForUnit(x) == 'Fractional inches'))
units.SetFormatOptions(target_spec, target_unit)
Output:
Exception : Microsoft.Scripting.ArgumentTypeException: expected UnitType, got ForgeTypeId
at Microsoft.Scripting.Interpreter.ThrowInstruction.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run5[T0,T1,T2,T3,T4,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at Microsoft.Scripting.Interpreter.DynamicInstruction`5.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1)
at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx)
at Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope)
at Microsoft.Scripting.Hosting.ScriptSource.ExecuteAndWrap(ScriptScope scope, ObjectHandle& exception)
Expected behavior
RevitPythonShell should execute SetFormatOptions(ForgeTypeId, FormatOptions) and set the specified unit.
Screenshots
Desktop (please complete the following information):
OS: Windows 10
Revit version 2021.1.7
RevitPythonShell version 2021.0.0.0
Additional context
The tooltip indicates that both SetFormatOptions(UnitType, FormatOptions) and SetFormatOptions(ForgeTypeId, FormatOptions) are available.
Describe the bug DB.Units.SetFormatOptions() expects
UnitType
, but should also expectForgeTypeId
To Reproduce
Output:
Expected behavior RevitPythonShell should execute
SetFormatOptions(ForgeTypeId, FormatOptions)
and set the specified unit.Screenshots![image](https://user-images.githubusercontent.com/131693/196318123-3d10734f-1604-4911-a4cc-94c6b4656821.png)
Desktop (please complete the following information):
Additional context The tooltip indicates that both
SetFormatOptions(UnitType, FormatOptions)
andSetFormatOptions(ForgeTypeId, FormatOptions)
are available.SetFormatOptions API documentation