From 1fa7eb76c6558976eed8f70977464b2815c402dd Mon Sep 17 00:00:00 2001 From: Roy-043 Date: Fri, 15 Dec 2023 14:59:59 +0100 Subject: [PATCH] Draft: implement new get_param functions (step 6) See #11677 Added a parameter to the dictionary. The get_parameter and set_parameter functions now print a warning if a parameter is not found. --- src/Mod/Draft/draftutils/params.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Mod/Draft/draftutils/params.py b/src/Mod/Draft/draftutils/params.py index 516b2b0a19..fce3a67fc9 100644 --- a/src/Mod/Draft/draftutils/params.py +++ b/src/Mod/Draft/draftutils/params.py @@ -369,6 +369,7 @@ def _get_param_dictionary(): "Draft_array_Link": ("bool", True), "fillmode": ("bool", True), "GlobalMode": ("bool", False), + "GridHideInOtherWorkbenches": ("bool", True), "HatchPatternResolution": ("int", 128), "HatchPatternRotation": ("float", 0.0), "HatchPatternScale": ("float", 100.0), @@ -512,7 +513,6 @@ def _get_param_dictionary(): PARAM_DICT = _get_param_dictionary() -# get_param("gridSpacing") def get_param(entry, path="Mod/Draft"): """Return a stored parameter value or its default. @@ -529,9 +529,8 @@ def get_param(entry, path="Mod/Draft"): ------- bool, float, int or str (if successful) or `None`. """ - if path not in PARAM_DICT: - return None - if entry not in PARAM_DICT[path]: + if path not in PARAM_DICT or entry not in PARAM_DICT[path]: + print(f"draftutils.params.get_param: Unable to find '{entry}' in '{path}'") return None param_grp = App.ParamGet("User parameter:BaseApp/Preferences/" + path) typ, default = PARAM_DICT[path][entry] @@ -574,9 +573,8 @@ def set_param(entry, value, path="Mod/Draft"): ------- `True` (if successful) or `False`. """ - if path not in PARAM_DICT: - return False - if entry not in PARAM_DICT[path]: + if path not in PARAM_DICT or entry not in PARAM_DICT[path]: + print(f"draftutils.params.set_param: Unable to find '{entry}' in '{path}'") return False param_grp = App.ParamGet("User parameter:BaseApp/Preferences/" + path) typ = PARAM_DICT[path][entry][0]