Salome HOME
Unit tests:
[modules/shaper.git] / src / PythonAPI / model / features / extrusion_boolean.py
index a5b3f8804ff58b08f2804820d0cb6e3de82d57fd..199d1e1d990a691e361646e63f3cac7c3f929e54 100644 (file)
@@ -7,9 +7,32 @@ from .roots import CompositeBoolean
 
 
 def addExtrusionCut(part, *args):
-    """Add an ExtrusionCut feature to the Part and return ExtrusionBoolean.
-
-    Pass all args to Extrusion __init__ function.
+    """Add an ExtrusionCut feature to the Part.
+
+    .. function:: addExtrusionCut(part, sketch, sketch_selection, boolean_objects, to_size, from_size)
+
+    Args:
+        part (ModelAPI_Document): part document
+        sketch (ModelAPI_Object): sketch feature
+        sketch_selection (Selection): sketch objects
+        boolean_objects (list of Selection): boolean objects
+        to_size (double): upper size of the extrusion
+        from_size (double): lower size of the extrusion
+
+    .. function:: addExtrusionCut(part, sketch, sketch_selection, boolean_objects, to_object, to_offset, from_object, from_offset)
+
+    Args:
+        part (ModelAPI_Document): part document
+        sketch (ModelAPI_Object): sketch feature
+        sketch_selection (Selection): sketch objects
+        boolean_objects (list of Selection): boolean objects
+        to_object (Selection): upper plane
+        to_offset (double): offset from upper plane
+        from_object (Selection): lower plane
+        from_offset (double): offset from lower plane
+
+    Returns:
+        ExtrusionBoolean: extrusion boolean object
     """
     assert(args)
     feature = part.addFeature("ExtrusionCut")
@@ -18,7 +41,30 @@ def addExtrusionCut(part, *args):
 def addExtrusionFuse(part, *args):
     """Add an ExtrusionFuse feature to the Part and return ExtrusionBoolean.
 
-    Pass all args to Extrusion __init__ function.
+    .. function:: addExtrusionFuse(part, sketch, sketch_selection, boolean_objects, to_size, from_size)
+
+    Args:
+        part (ModelAPI_Document): part document
+        sketch (ModelAPI_Object): sketch feature
+        sketch_selection (Selection): sketch objects
+        boolean_objects (list of Selection): boolean objects
+        to_size (double): upper size of the extrusion
+        from_size (double): lower size of the extrusion
+
+    .. function:: addExtrusionFuse(part, sketch, sketch_selection, boolean_objects, to_object, to_offset, from_object, from_offset)
+
+    Args:
+        part (ModelAPI_Document): part document
+        sketch (ModelAPI_Object): sketch feature
+        sketch_selection (Selection): sketch objects
+        boolean_objects (list of Selection): boolean objects
+        to_object (Selection): upper plane
+        to_offset (double): offset from upper plane
+        from_object (Selection): lower plane
+        from_offset (double): offset from lower plane
+
+    Returns:
+        ExtrusionBoolean: extrusion boolean object
     """
     assert(args)
     feature = part.addFeature("ExtrusionFuse")
@@ -26,9 +72,30 @@ def addExtrusionFuse(part, *args):
 
 
 class ExtrusionBoolean(CompositeBoolean):
+    """Interface class for ExtrusionBoolean features.
+
+    Supported features:
+
+    * ExtrusionCut
+    * ExtrusionFuse
+
+    .. function:: ExtrusionBoolean(feature)
+
+        Create interface for the feature without initialization.
+
+    .. function:: ExtrusionBoolean(feature, sketch, sketch_selection, boolean_objects, to_size, from_size)
+
+        Create interface for the feature and initialize the feature with arguments.
+
+    .. function:: ExtrusionBoolean(feature, sketch, sketch_selection, boolean_objects, to_object, to_offset, from_object, from_offset)
+
+        Create interface for the feature and initialize the feature with arguments.
+    """
 
     def __init__(self, feature, *args):
-        CompositeBoolean.__init__(self, feature, *args)
+        """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
+        CompositeBoolean.__init__(self, feature, *args[:3])
+        args = args[3:]
 
         self._CreationMethod = self._feature.string("CreationMethod")
         self._to_size = self._feature.data().real("to_size")
@@ -49,21 +116,23 @@ class ExtrusionBoolean(CompositeBoolean):
         if not args:
             return
 
-        assert(len(args) == 4 or len(args) == 2)
+        assert(len(args) in (2, 4))
         if len(args) == 4:
             self.setPlanesAndOffsets(*args)
         elif len(args) == 2:
             self.setSizes(*args)
+
+        self.execute()
         pass
 
     def __clear(self):
         self._CreationMethod.setValue("BySizes")
-        self._fill_attribute(self._to_size, 0)
-        self._fill_attribute(self._from_size, 0)
-        self._fill_attribute(self._to_object, None)
-        self._fill_attribute(self._to_offset, 0)
-        self._fill_attribute(self._from_object, None)
-        self._fill_attribute(self._from_offset, 0)
+        self._fillAttribute(self._to_size, 0)
+        self._fillAttribute(self._from_size, 0)
+        self._fillAttribute(self._to_object, None)
+        self._fillAttribute(self._to_offset, 0)
+        self._fillAttribute(self._from_object, None)
+        self._fillAttribute(self._from_offset, 0)
         pass
 
     def setSizes(self, to_size, from_size):
@@ -73,8 +142,8 @@ class ExtrusionBoolean(CompositeBoolean):
         """
         self.__clear()
         self._CreationMethod.setValue("BySizes")
-        self._fill_attribute(self._to_size, to_size)
-        self._fill_attribute(self._from_size, from_size)
+        self._fillAttribute(self._to_size, to_size)
+        self._fillAttribute(self._from_size, from_size)
         pass
 
     def setPlanesAndOffsets(self, to_object, to_offset,
@@ -85,9 +154,9 @@ class ExtrusionBoolean(CompositeBoolean):
         """
         self.__clear()
         self._CreationMethod.setValue("ByPlanesAndOffsets")
-        self._fill_attribute(self._to_object, to_object)
-        self._fill_attribute(self._to_offset, to_offset)
-        self._fill_attribute(self._from_object, from_object)
-        self._fill_attribute(self._from_offset, from_offset)
+        self._fillAttribute(self._to_object, to_object)
+        self._fillAttribute(self._to_offset, to_offset)
+        self._fillAttribute(self._from_object, from_object)
+        self._fillAttribute(self._from_offset, from_offset)
         pass