2 Author: Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
6 from model.roots import Interface
9 def addPlane(part, *args):
10 """Add a Plane feature to the Part and return Plane.
12 Pass all args to Plane __init__ function.
14 feature = part.addFeature("Plane")
15 return Plane(feature, *args)
18 class Plane(Interface):
19 """Interface on a Plane feature."""
21 def __init__(self, feature, *args):
22 """Initialize a Plane feature with given parameters.
24 Expected arguments for all modes:
25 feature -- a Plane feature
27 For PlaneByFaceAndDistance mode (expect 2 arguments):
31 For PlaneByGeneralEquation mode (expect 4 arguments):
32 A, B, C, D -- GeneralEquation parameters
34 Interface.__init__(self, feature)
35 assert(self._feature.getKind() == "Plane")
37 self._CreationMethod = self._feature.data().string("CreationMethod")
38 self._plane_face = self._feature.data().selection("planeFace")
39 self._distance = self._feature.data().real("distance")
40 self._a = self._feature.data().real("A")
41 self._b = self._feature.data().real("B")
42 self._c = self._feature.data().real("C")
43 self._d = self._feature.data().real("D")
45 assert(self._CreationMethod)
46 assert(self._plane_face)
47 assert(self._distance)
56 assert(len(args) == 2 or len(args) == 4)
58 self.setFaceAndDistance(*args)
60 self.setGeneralEquation(*args)
64 self._fill_attribute(self._CreationMethod, "PlaneByFaceAndDistance")
65 self._fill_attribute(self._plane_face, None)
66 self._fill_attribute(self._distance, 0)
67 self._fill_attribute(self._a, 0)
68 self._fill_attribute(self._b, 0)
69 self._fill_attribute(self._c, 0)
70 self._fill_attribute(self._d, 0)
72 def setFaceAndDistance(self, face, distance):
73 """Modify face and distance attribute of the feature.
78 self._fill_attribute(self._CreationMethod, "PlaneByFaceAndDistance")
79 self._fill_attribute(self._plane_face, face)
80 self._fill_attribute(self._distance, distance)
83 def setGeneralEquation(self, a, b, c, d):
84 """Modify GeneralEquation parameters of the feature.
89 self._fill_attribute(self._CreationMethod, "PlaneByGeneralEquation")
90 self._fill_attribute(self._a, a)
91 self._fill_attribute(self._b, b)
92 self._fill_attribute(self._c, c)
93 self._fill_attribute(self._d, d)