From dd58494553235a7ff45281a71e450f54dbe4cc89 Mon Sep 17 00:00:00 2001 From: Peter Ludikar Date: Fri, 5 Jul 2024 21:27:11 -0400 Subject: [PATCH] added parameter mode check --- UserParameter.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/UserParameter.py b/UserParameter.py index 03df4a3..884d7ef 100644 --- a/UserParameter.py +++ b/UserParameter.py @@ -7,6 +7,7 @@ _app = adsk.core.Application.get() _design: adsk.fusion.Design = cast(adsk.fusion.Design, _app.activeProduct) +_ui = _app.userInterface DB_TOOL_DIA = "dbToolDia" DB_OFFSET = "dbOffset" @@ -15,7 +16,22 @@ DB_RADIUS = "dbRadius" COMMENT = "Do NOT change formula" -userParams: adsk.fusion.UserParameters = _design.userParameters + +try: + userParams: adsk.fusion.UserParameters = _design.userParameters +except RuntimeError: + if _design.designType != adsk.fusion.DesignTypes.ParametricDesignType: + returnValue = _ui.messageBox( + "DogBone only works in Parametric Mode \n Do you want to change modes?", + "Change to Parametric mode", + adsk.core.MessageBoxButtonTypes.YesNoButtonType, + adsk.core.MessageBoxIconTypes.WarningIconType, + ) + if returnValue != adsk.core.DialogResults.DialogYes: + raise RuntimeError("DogBone only works in Parametric Mode") + _design.designType = adsk.fusion.DesignTypes.ParametricDesignType + + default_length_units = _design.unitsManager.defaultLengthUnits