From 568588fcb48926f784fdfa8610b0dd72940abd05 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 26 Apr 2016 10:01:33 +0300 Subject: [PATCH] Issue #1440 Crash when edit box with parameter: height of the box using parameter text --- src/PythonAPI/model/features/extrusion.py | 21 ++++++++++++++++----- src/PythonAddons/macros/box/feature.py | 14 +++++++++----- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/PythonAPI/model/features/extrusion.py b/src/PythonAPI/model/features/extrusion.py index f0cb7c403..7e87ace83 100644 --- a/src/PythonAPI/model/features/extrusion.py +++ b/src/PythonAPI/model/features/extrusion.py @@ -126,7 +126,7 @@ class Extrusion(Interface): self._fillAttribute(self._base, base) pass - def setSizes(self, to_size, from_size): + def setSizes(self, to_size, from_size, to_size_text="", from_size_text=""): """Modify the to_size, from_size attributes of the feature. See __init__. @@ -136,23 +136,34 @@ class Extrusion(Interface): # values without changes that causes cyclic dependency #self.__clear() self._fillAttribute(self._CreationMethod, "BySizes") - self._fillAttribute(self._to_size, to_size) - self._fillAttribute(self._from_size, from_size) + if to_size_text == "": + self._fillAttribute(self._to_size, to_size) + else: + self._fillAttribute(self._to_size, to_size_text) + + if from_size_text == "": + self._fillAttribute(self._from_size, from_size) + else: + self._fillAttribute(self._to_size, from_size_text) pass - def setSize(self, size): + def setSize(self, size, text=""): """Modify the size of the feature. If size is positive then initialize to_size with size. If size is negative then initialize from_size with -size. """ to_size, from_size = 0, 0 + to_size_text, from_size_text = "", "" if size >= 0: to_size = size + to_size_text = text else: from_size = -size + from_size_text = text + + self.setSizes(to_size, from_size, to_size_text, from_size_text) - self.setSizes(to_size, from_size) pass def setPlanesAndOffsets(self, to_object, to_offset, diff --git a/src/PythonAddons/macros/box/feature.py b/src/PythonAddons/macros/box/feature.py index 4238622c6..6341e432a 100644 --- a/src/PythonAddons/macros/box/feature.py +++ b/src/PythonAddons/macros/box/feature.py @@ -95,13 +95,17 @@ class BoxFeature(model.Feature): height_text = self.getTextInput(self.HEIGHT_ID()) # Editing the box - self.base.setValue(self.width, width) - self.base.setText(self.width, width_text) + if width_text == "": + self.base.setValue(self.width, width) + else: + self.base.setText(self.width, width_text) - self.base.setValue(self.length, length) - self.base.setText(self.length, length_text) + if length_text != "": + self.base.setValue(self.length, length) + else: + self.base.setText(self.length, length_text) - self.box.setSize(height) + self.box.setSize(height, height_text) # Publishing the result: not needed for Macro feature # self.addResult( self.box.result() ) -- 2.39.2