From: spo Date: Thu, 22 Oct 2015 06:57:24 +0000 (+0300) Subject: Make addBox as a function. X-Git-Tag: V_2.1.0~206^2~79^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7af987ce01755058718fb1ece59b50218a9dad07;p=modules%2Fshaper.git Make addBox as a function. --- diff --git a/src/PythonAPI/extension/__init__.py b/src/PythonAPI/extension/__init__.py index 275cb5503..b57f516a1 100644 --- a/src/PythonAPI/extension/__init__.py +++ b/src/PythonAPI/extension/__init__.py @@ -1,4 +1,4 @@ """User-defined features. """ -from box import Box as addBox \ No newline at end of file +from box import addBox \ No newline at end of file diff --git a/src/PythonAPI/extension/box.py b/src/PythonAPI/extension/box.py index e0e866c20..9377fe345 100644 --- a/src/PythonAPI/extension/box.py +++ b/src/PythonAPI/extension/box.py @@ -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")