2 Author: Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
6 from model.roots import Interface
9 def addPartition(part, *args):
10 """Add a Partition feature to the Part.
12 .. function:: addPartition(part, main_objects, tool_objects, partition_combine)
15 part (ModelAPI_Document): part document
16 main_objects (list of Selection): main objects
17 tool_objects (list of Selection): tool objects
18 partition_combine (boolean):
19 If True combines all results to one. If False builds separate result for each object.
22 Partition: partition object
24 assert(len(args) > 0 and args[0] is not None)
25 feature = part.addFeature("Partition")
26 return Partition(feature, *args)
29 class Partition(Interface):
30 """Interface class for Partition feature.
32 .. function:: Partition(feature)
34 Create interface for the feature without initialization.
36 .. function:: Partition(feature, main_objects, tool_objects, partition_combine)
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() == "Partition")
46 self._main_objects = self._feature.data().selectionList("main_objects")
47 self._tool_objects = self._feature.data().selectionList("tool_objects")
48 self._partition_combine = self._feature.data().boolean("partition_combine")
50 assert(self._main_objects)
51 assert(self._tool_objects)
52 assert(self._partition_combine)
57 assert(len(args) == 3)
58 main_objects, tool_objects, partition_combine = args
60 self.setMainObjects(main_objects)
61 self.setToolObjects(tool_objects)
62 self.setPartitionCombine(partition_combine)
67 def setMainObjects(self, main_objects):
68 """Modify base attribute of the feature.
72 self._fillAttribute(self._main_objects, main_objects)
75 def setToolObjects(self, tool_objects):
76 """Modify the to_size, from_size attributes of the feature.
80 self._fillAttribute(self._tool_objects, tool_objects)
83 def setPartitionCombine(self, partition_combine):
84 """Modify planes and offsets attributes of the feature.
88 self._fillAttribute(self._partition_combine, partition_combine)