Salome HOME
Issue #1440 Crash when edit box with parameter: height of the box using parameter...
[modules/shaper.git] / src / PythonAPI / model / features / extrusion.py
index a93cf49423db6cb02811b9bcb506648d756262be..7e87ace83ac5cc411f4e2862e5d371f10ba6489a 100644 (file)
@@ -9,33 +9,33 @@ from model import Selection
 
 def addExtrusion(part, *args):
     """Add an Extrusion feature to the Part and return Extrusion.
-    
+
     This function has *3 signatures*:
-    
+
     .. function:: addExtrusion(base, size)
-    
+
     Arguments:
         base(str, Sketch or list): base object(s)
         size(double): size of the extrusion, the side is decided by the sign
-    
+
     .. function:: addExtrusion(base, to_size, from_size)
-    
+
     Arguments:
         base(str, Sketch or list): base object(s)
         to_size(double): upper size of the extrusion
         from_size(double): lower size of the extrusion
-    
+
     .. function:: addExtrusion(base, to_object, to_offset, from_object, from_offset)
-    
+
     Arguments:
         base(str, Sketch or list): base object(s)
-        to_object(plane): upper object
+        to_object(plane): upper plane
         to_offset(double): offset from upper object
         from_object(plane): lower plane
         from_offset(double): offset from lower plane
-        
+
     In all three cases the function returns an extrusion object
-    
+
     Returns:
         Extrusion: extrusion object
     """
@@ -126,30 +126,44 @@ 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__.
         """
-        self.__clear()
+        # MPV: with "clear" calling here the extrusion all the time becomes modificed (height is set to 
+        # zero and then to actual value, but this function is used in macro Bax, that causes "modified"
+        # 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,