]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
[PythonAPI] For addAddition() feature make tool_objects parameter as optional
authorspo <sergey.pokhodenko@opencascade.com>
Fri, 18 Dec 2015 12:56:11 +0000 (15:56 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 18 Dec 2015 12:56:11 +0000 (15:56 +0300)
src/PythonAPI/examples/Platine.py
src/PythonAPI/model/features/boolean.py

index 0d9e4e53697e46e66673754cc3536acfc61eb4a6..e71c50ae6030e43bef5cc3ee7060bfa1046be5c1 100644 (file)
@@ -189,15 +189,15 @@ def body_4():
 b1 = vertical_body()
 b2 = bottom_body()
 
-boolean = model.addAddition(part, b1.result() + b2.result(), [])
+boolean = model.addAddition(part, b1.result() + b2.result())
 model.do()
 
 b3 = body_3()
 
-boolean = model.addAddition(part, boolean.result() + b3.result(), [])
+boolean = model.addAddition(part, boolean.result() + b3.result())
 model.do()
 
 b4 = body_4()
 
-boolean = model.addAddition(part, boolean.result() + b4.result(), [])
+boolean = model.addAddition(part, boolean.result() + b4.result())
 model.do()
index 00085cd4c44c772b9c8eeb2126db212d5b6e5ef8..aab909faaf543c5929f7d31dfe140c849eafb541 100644 (file)
@@ -18,16 +18,15 @@ def addAddition(part, *args):
     Args:
         part (ModelAPI_Document): part document
         main_objects (list of :class:`model.Selection`): main objects
-        tool_objects (list of :class:`model.Selection`): tool_objects objects
+        tool_objects (list of :class:`model.Selection`): (optional) tool_objects objects
 
     Returns:
         Boolean: boolean object
     """
     assert(args)
-    main_objects, tool_objects = args
     feature = part.addFeature("Boolean")
     return Boolean(
-        feature, main_objects, tool_objects, GeomAlgoAPI_Boolean.BOOL_FUSE)
+        feature, GeomAlgoAPI_Boolean.BOOL_FUSE, *args)
 
 
 def addSubtraction(part, *args):
@@ -49,7 +48,7 @@ def addSubtraction(part, *args):
     main_objects, tool_objects = args
     feature = part.addFeature("Boolean")
     return Boolean(
-        feature, main_objects, tool_objects, GeomAlgoAPI_Boolean.BOOL_CUT)
+        feature, GeomAlgoAPI_Boolean.BOOL_CUT, main_objects, tool_objects)
 
 
 def addIntersection(part, *args):
@@ -71,7 +70,7 @@ def addIntersection(part, *args):
     main_objects, tool_objects = args
     feature = part.addFeature("Boolean")
     return Boolean(
-        feature, main_objects, tool_objects, GeomAlgoAPI_Boolean.BOOL_COMMON)
+        feature, GeomAlgoAPI_Boolean.BOOL_COMMON, main_objects, tool_objects)
 
 
 class Boolean(Interface):
@@ -81,7 +80,11 @@ class Boolean(Interface):
 
         Create interface for the feature without initialization.
 
-    .. function:: Boolean(feature, main_objects, tool_objects, bool_type)
+    .. function:: Boolean(feature, bool_type, main_objects)
+
+        Create interface for the feature and initialize the feature with arguments.
+
+    .. function:: Boolean(feature, bool_type, main_objects, tool_objects)
 
         Create interface for the feature and initialize the feature with arguments.
     """
@@ -102,12 +105,15 @@ class Boolean(Interface):
         if not args:
             return
 
-        assert(len(args) == 3)
-        main_objects, tool_objects, bool_type = args
+        assert(len(args) in (2, 3))
+        bool_type, main_objects = args[:2]
 
-        self.setMainObjects(main_objects)
-        self.setToolObjects(tool_objects)
         self.setBoolType(bool_type)
+        self.setMainObjects(main_objects)
+
+        if len(args) == 3:
+            tool_objects = args[2]
+            self.setToolObjects(tool_objects)
 
         self.execute()
         pass