Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB.Units.SetFormatOptions() does not accept expect ForgeTypeId #134

Open
onomou opened this issue Oct 18, 2022 · 0 comments
Open

DB.Units.SetFormatOptions() does not accept expect ForgeTypeId #134

onomou opened this issue Oct 18, 2022 · 0 comments

Comments

@onomou
Copy link

onomou commented Oct 18, 2022

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
image

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.

SetFormatOptions API documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant