From d18ba9010d4b9ce18bd0cc54a0682dc92e0b6e50 Mon Sep 17 00:00:00 2001 From: Roy-043 Date: Wed, 26 Mar 2025 11:03:21 +0100 Subject: [PATCH 1/2] BIM: Remove calls to obsolete Draft.getParam See #20198. --- src/Mod/BIM/bimcommands/BimProjectManager.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Mod/BIM/bimcommands/BimProjectManager.py b/src/Mod/BIM/bimcommands/BimProjectManager.py index 83213f75df..c0bf3d6ff2 100644 --- a/src/Mod/BIM/bimcommands/BimProjectManager.py +++ b/src/Mod/BIM/bimcommands/BimProjectManager.py @@ -145,6 +145,7 @@ class BIM_ProjectManager: import Draft import FreeCADGui import Part + from draftutils import params vaxes = [] haxes = [] @@ -307,8 +308,8 @@ class BIM_ProjectManager: outtext = Draft.make_text( [buildingname], FreeCAD.Vector( - Draft.getParam("textheight", 0.20) * 0.3, - -Draft.getParam("textheight", 0.20) * 1.43, + params.get_param("textheight") * 0.3, + -params.get_param("textheight") * 1.43, 0, ), ) @@ -325,8 +326,8 @@ class BIM_ProjectManager: axisV.Label = translate("BIM", "Vertical Axes") axisV.ViewObject.BubblePosition = "Both" axisV.ViewObject.LineWidth = self.form.lineWidth.value() - axisV.ViewObject.FontSize = Draft.getParam("textheight", 0.20) - axisV.ViewObject.BubbleSize = Draft.getParam("textheight", 0.20) * 1.43 + axisV.ViewObject.FontSize = params.get_param("textheight") + axisV.ViewObject.BubbleSize = params.get_param("textheight") * 1.43 axisV.ViewObject.LineColor = color axisH = None if self.form.countHAxes.value() and distHAxes: @@ -337,8 +338,8 @@ class BIM_ProjectManager: axisH.ViewObject.BubblePosition = "Both" axisH.ViewObject.NumberingStyle = "A,B,C" axisH.ViewObject.LineWidth = self.form.lineWidth.value() - axisH.ViewObject.FontSize = Draft.getParam("textheight", 0.20) - axisH.ViewObject.BubbleSize = Draft.getParam("textheight", 0.20) * 1.43 + axisH.ViewObject.FontSize = params.get_param("textheight") + axisH.ViewObject.BubbleSize = params.get_param("textheight") * 1.43 axisH.Placement.Rotation = FreeCAD.Rotation(FreeCAD.Vector(0, 0, 1), 90) axisH.ViewObject.LineColor = color if axisV and axisH: From 0c9c23dc18086c1b255d8b9b1440501cd5ca6c7b Mon Sep 17 00:00:00 2001 From: Roy-043 Date: Wed, 26 Mar 2025 15:49:30 +0100 Subject: [PATCH 2/2] Draft: remove obsolete param functions See #20198 These functions are no longer used in the Draft WB or in the BIM WB. There is a small risk that 3rd party code relies on them and breaks, but that can be addressed when such is reported as a problem. --- src/Mod/Draft/Draft.py | 4 -- src/Mod/Draft/draftutils/utils.py | 78 ------------------------------- 2 files changed, 82 deletions(-) diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index 8899b38bf4..1d05ec41fc 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -54,10 +54,6 @@ from draftutils.utils import ARROW_TYPES as arrowtypes from draftutils.utils import (type_check, typecheck, - get_param, - getParam, - set_param, - setParam, precision, tolerance) diff --git a/src/Mod/Draft/draftutils/utils.py b/src/Mod/Draft/draftutils/utils.py index 284f5d7bc1..cb97c82441 100644 --- a/src/Mod/Draft/draftutils/utils.py +++ b/src/Mod/Draft/draftutils/utils.py @@ -183,84 +183,6 @@ def type_check(args_and_types, name="?"): typecheck = type_check -def get_param(param, default=None): - """Return a parameter value from the current parameter database. - - The parameter database is located in the tree - :: - 'User parameter:BaseApp/Preferences/Mod/Draft' - - In the case that `param` is `'linewidth'` or `'color'` it will get - the values from the View parameters - :: - 'User parameter:BaseApp/Preferences/View/DefaultShapeLineWidth' - 'User parameter:BaseApp/Preferences/View/DefaultShapeLineColor' - - Parameters - ---------- - param : str - A string that indicates a parameter in the parameter database. - - default : optional - It indicates the default value of the given parameter. - It defaults to `None`, in which case it will use a specific - value depending on the type of parameter determined - with `get_param_type`. - - Returns - ------- - int, or str, or float, or bool - Depending on `param` and its type. - """ - if param == "linewidth": - return params.get_param("DefaultShapeLineWidth", path="View") - elif param == "color": - return params.get_param("DefaultShapeLineColor", path="View") - else: - return params.get_param(param) - - -getParam = get_param - - -def set_param(param, value): - """Set a Draft parameter with the given value. - - The parameter database is located in the tree - :: - 'User parameter:BaseApp/Preferences/Mod/Draft' - - In the case that `param` is `'linewidth'` or `'color'` it will set - the View parameters - :: - 'User parameter:BaseApp/Preferences/View/DefaultShapeLineWidth' - 'User parameter:BaseApp/Preferences/View/DefaultShapeLineColor' - - Parameters - ---------- - param : str - A string that indicates a parameter in the parameter database. - - value : int, or str, or float, or bool - The appropriate value of the parameter. - Depending on `param` and its type, determined with `get_param_type`, - it sets the appropriate value by calling `ParameterGrp.SetInt`, - `ParameterGrp.SetString`, `ParameterGrp.SetFloat`, - `ParameterGrp.SetBool`, or `ParameterGrp.SetUnsinged`. - """ - if param == "linewidth": - return params.set_param("DefaultShapeLineWidth", value, path="View") - elif param == "color": - return params.set_param("DefaultShapeLineColor", value, path="View") - else: - return params.set_param(param, value) - - - - -setParam = set_param - - def precision(): """Return the precision value from the parameter database.