From 7af987ce01755058718fb1ece59b50218a9dad07 Mon Sep 17 00:00:00 2001 From: spo Date: Thu, 22 Oct 2015 09:57:24 +0300 Subject: [PATCH] Make addBox as a function. --- src/PythonAPI/extension/__init__.py | 2 +- src/PythonAPI/extension/box.py | 31 +++++++++++++++++------------ 2 files changed, 19 insertions(+), 14 deletions(-) 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") -- 2.39.2