]> SALOME platform Git repositories - modules/shaper.git/blob - src/PythonAPI/model/partset/part.py
Salome HOME
Fix Platine test
[modules/shaper.git] / src / PythonAPI / model / partset / part.py
1 """Part Feature Interface
2 Author: Daniel Brunier-Coulin
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 """
5
6 import ModelAPI
7
8 from model.roots import Interface
9
10
11 def addPart(partset):
12     """Add a Part feature to the Part and return Part.
13
14     Args:
15         partset (ModelAPI_Document): partset document
16
17     Returns:
18         Part: part object
19     """
20     feature = partset.addFeature("Part")
21     return Part(feature)
22
23 def duplicatePart(part):
24     """Create a copy of the Part.
25
26     Args:
27         part (ModelAPI_Document): part document
28
29     Returns:
30         Part: part object
31     """
32     feature = part.addFeature("Duplicate")
33     feature.execute()
34     return Part(feature)
35
36 def removePart(part):
37     """Remove the Part.
38
39     Args:
40         part (ModelAPI_Document): part document
41     """
42     feature = part.addFeature("Remove")
43     feature.execute()
44
45
46 class Part(Interface):
47     """Interface class for Part feature.
48
49     .. function:: Part(feature)
50
51         Create interface for the feature without initialization.
52     """
53
54     def __init__(self, feature):
55         """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
56         Interface.__init__(self, feature)
57         assert(self._feature.getKind() == "Part")
58
59         self.execute()
60         pass
61
62     def document(self):
63         """Returns the Part document created by this feature."""
64         result_part = ModelAPI.modelAPI_ResultPart(self._feature.firstResult())
65         return result_part.partDoc()