From c6198fb3e13375785bbf471c0ff4fb5336fe6226 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 22 Apr 2016 17:55:59 +0300 Subject: [PATCH] Issue #1440 Crash when edit box with parameter: correction for using parameter values in sketch lengths --- src/PythonAPI/model/roots.py | 4 ++++ src/PythonAPI/model/sketcher/sketch.py | 10 ++++++++++ src/PythonAddons/macros/box/feature.py | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/src/PythonAPI/model/roots.py b/src/PythonAPI/model/roots.py index 5f1c294bf..2ba6a21de 100644 --- a/src/PythonAPI/model/roots.py +++ b/src/PythonAPI/model/roots.py @@ -24,6 +24,10 @@ class Feature(ModelAPI.ModelAPI_Feature): """F.getRealInput(str) -- get real value of the attribute""" return self.data().real(inputid).value() + def getTextInput(self, inputid): + """F.getTextInput(str) -- get text value of the attribute""" + return self.data().real(inputid).text() + def addResult(self, result): """F.addResult(ModelAPI_Result) -- add ModelAPI_Result shape as a result""" shape = result.shape() diff --git a/src/PythonAPI/model/sketcher/sketch.py b/src/PythonAPI/model/sketcher/sketch.py index 5303f7df5..611e5d2ac 100644 --- a/src/PythonAPI/model/sketcher/sketch.py +++ b/src/PythonAPI/model/sketcher/sketch.py @@ -362,6 +362,16 @@ class Sketch(Interface): """Modify the value of the given dimensional constraint.""" constraint.data().real("ConstraintValue").setValue(value) + #------------------------------------------------------------- + # + # Edition of Dimensional Constraints + # + #------------------------------------------------------------- + + def setText(self, constraint, text): + """Modify the value of the given dimensional constraint.""" + constraint.data().real("ConstraintValue").setText(text) + #------------------------------------------------------------- # # Macro functions combining geometry creation and constraints diff --git a/src/PythonAddons/macros/box/feature.py b/src/PythonAddons/macros/box/feature.py index 1d3f02f07..5100db2c6 100644 --- a/src/PythonAddons/macros/box/feature.py +++ b/src/PythonAddons/macros/box/feature.py @@ -90,9 +90,17 @@ class BoxFeature(model.Feature): length = self.getRealInput(self.LENGTH_ID()) height = self.getRealInput(self.HEIGHT_ID()) + width_text = self.getTextInput(self.WIDTH_ID()) + length_text = self.getRealInput(self.LENGTH_ID()) + height_text = self.getRealInput(self.HEIGHT_ID()) + # Editing the box self.base.setValue(self.width, width) + self.base.setText(self.width, width_text) + self.base.setValue(self.length, length) + self.base.setText(self.width, length_text) + self.box.setSize(height) # Publishing the result: not needed for Macro feature -- 2.39.2