Salome HOME
Make addBox as a function.
[modules/shaper.git] / src / PythonAPI / extension / box.py
index e0e866c20b7cb5f632c1086bc72a36351b21e4e1..9377fe345310b0b219bc0a51db86670c5048d0dc 100644 (file)
@@ -7,17 +7,22 @@ import model
 from macros.box.feature import BoxFeature as MY
 
 
+def addBox(self, container, *args):
+    feature = container.addFeature(MY.ID())
+    return Box(feature, *args)
+
+
 class Box(model.Interface):
-  """Executes the macro-feature Box.
-  """
-  def __init__(self, part, dx, dy, dz):
-    model.Interface.__init__(self, part, MY.ID())
-
-    self.setRealInput( MY.WIDTH_ID(), dx )
-    self.setRealInput( MY.LENGTH_ID(), dy )
-    self.setRealInput( MY.HEIGHT_ID(), dz )
-
-    if self.areInputValid():
-      self.execute()
-    else:
-      raise Exception("cannot make the Box")
\ No newline at end of file
+    """Executes the macro-feature Box."""
+
+    def __init__(self, feature, dx, dy, dz):
+        model.Interface.__init__(self, feature)
+
+        self.setRealInput(MY.WIDTH_ID(), dx)
+        self.setRealInput(MY.LENGTH_ID(), dy)
+        self.setRealInput(MY.HEIGHT_ID(), dz)
+
+        if self.areInputValid():
+            self.execute()
+        else:
+            raise Exception("cannot make the Box")