1 """Abstract root classes of user-defined Python features producing a Body
2 Author: Daniel Brunier-Coulin
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
10 class Feature(ModelAPI.ModelAPI_Feature):
11 """Base class of user-defined Python features."""
14 ModelAPI.ModelAPI_Feature.__init__(self)
16 def addRealInput (self, inputid):
17 self.data().addAttribute(inputid,
18 ModelAPI.ModelAPI_AttributeDouble_typeId())
20 def getRealInput (self, inputid):
21 return self.data().real(inputid).value()
23 def addResult (self, result):
24 shape = result.shape()
25 body = self.document().createBody(self.data())
31 """Base class of hight level Python interfaces to features."""
33 def __init__(self, feature):
34 self._feature = feature
36 def __getattr__(self, name):
37 """Process missing attributes.
39 Redirect missing attributes to the feature.
41 return self._feature.__getattribute__(name)
43 def setRealInput (self, inputid, value):
44 self._feature.data().real(inputid).setValue(value)
46 def areInputValid (self):
47 validators = ModelAPI.ModelAPI_Session.get().validators()
48 return validators.validate(self._feature)
51 self._feature.execute()