]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Add parameter feature without tests.
authorspo <sergey.pokhodenko@opencascade.com>
Tue, 27 Oct 2015 08:49:11 +0000 (11:49 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Tue, 27 Oct 2015 08:49:11 +0000 (11:49 +0300)
src/PythonAPI/model/__init__.py
src/PythonAPI/model/parameter/__init__.py [new file with mode: 0644]
src/PythonAPI/model/parameter/parameter.py [new file with mode: 0644]

index 1f90375a49a0758b9fbb3800a30aab3ffe477bb0..8dbf44e8ae64cc6b9774bb1c7e9132f4dfba58b7 100644 (file)
@@ -12,6 +12,7 @@ from part      import Part            as addPart
 from sketcher.sketch  import addSketch
 from construction import *
 from features import *
+from parameter import *
 
 # Custom exceptions
 
diff --git a/src/PythonAPI/model/parameter/__init__.py b/src/PythonAPI/model/parameter/__init__.py
new file mode 100644 (file)
index 0000000..44bde3f
--- /dev/null
@@ -0,0 +1,4 @@
+"""Package for Parameter plugin for the Parametric Geometry API of the Modeler.
+"""
+
+from parameter import addParameter
\ No newline at end of file
diff --git a/src/PythonAPI/model/parameter/parameter.py b/src/PythonAPI/model/parameter/parameter.py
new file mode 100644 (file)
index 0000000..7a5c28f
--- /dev/null
@@ -0,0 +1,60 @@
+"""Parameter Interface
+Author: Sergey Pokhodenko
+Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+"""
+
+from model.roots import Interface
+
+
+def addParameter(part, *args):
+    """Add a Parameter feature to the Part and return Parameter.
+
+    Pass all args to Parameter __init__ function.
+    """
+    feature = part.addFeature("Parameter")
+    return Parameter(feature, *args)
+
+
+class Parameter(Interface):
+    """Interface on a Parameter feature."""
+
+    def __init__(self, feature, *args):
+        """Initialize a Parameter feature with given parameters.
+
+        Expected arguments for all modes:
+        feature -- a Parameter feature
+
+        For initialization (expect 2 arguments):
+        name -- variable name
+        expression -- Python expression
+        """
+        Interface.__init__(self, feature)
+        assert(self._feature.getKind() == "Parameter")
+
+        self._CreationMethod = self._feature.data().string("CreationMethod")
+        self._variable = self._feature.data().selection("variable")
+        self._expression = self._feature.data().real("expression")
+
+        if not args:
+            return
+
+        assert(len(args) == 2)
+        self.setName(args[0])
+        self.setExpression(args[1])
+        pass
+
+    def setName(self, name):
+        """Modify variable name attribute of the feature.
+
+        See __init__.
+        """
+        self._fill_attribute(self._name, name)
+        pass
+
+    def setExpression(self, expression):
+        """Modify expression attribute of the feature.
+
+        See __init__.
+        """
+        self._fill_attribute(self._expression, expression)
+        pass