2 Author: Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
6 from model.roots import Interface
9 def addParameter(part, *args):
10 """Add a Parameter feature to the Part and return Parameter.
12 .. function:: addParameter(part, variable, expression)
15 part (ModelAPI_Document): part document
16 variable (string): variable name
17 expression (string): Python expression
20 Parameter: parameter object
22 Pass all args to Parameter __init__ function.
25 feature = part.addFeature("Parameter")
26 return Parameter(feature, *args)
29 class Parameter(Interface):
30 """Interface class for Parameter feature.
32 .. function:: Point(feature)
34 Create interface for the feature without initialization.
36 .. function:: Point(feature, variable, expression)
38 Create interface for the feature and initialize the feature with arguments.
41 def __init__(self, feature, *args):
42 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
43 Interface.__init__(self, feature)
44 assert(self._feature.getKind() == "Parameter")
46 self._variable = self._feature.string("variable")
47 self._expression = self._feature.string("expression")
49 assert(self._variable)
50 assert(self._expression)
55 assert(len(args) == 2)
57 self.setExpression(args[1])
62 def setName(self, name):
63 """Modify variable name attribute of the feature.
67 self._fillAttribute(self._variable, name)
70 def setExpression(self, expression):
71 """Modify expression attribute of the feature.
75 self._fillAttribute(self._expression, expression)