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 and return Partition.
12 Pass all args to Partition __init__ function.
14 assert(len(args) > 0 and args[0] is not None)
15 feature = part.addFeature("Partition")
16 return Partition(feature, *args)
19 class Partition(Interface):
20 """Interface class for Partition feature.
22 Partition(feature) -> feature interface without initialization
23 Partition(feature, main_objects, tool_objects, partition_combine) ->
24 feature interface initialized from arguments:
25 - main_objects -- list of solids
26 - tool_objects -- list of solids
27 - partition_combine -- boolean value
30 def __init__(self, feature, *args):
31 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
32 Interface.__init__(self, feature)
33 assert(self._feature.getKind() == "Partition")
35 self._main_objects = self._feature.data().selectionList("main_objects")
36 self._tool_objects = self._feature.data().selectionList("tool_objects")
37 self._partition_combine = self._feature.data().boolean("partition_combine")
39 assert(self._main_objects)
40 assert(self._tool_objects)
41 assert(self._partition_combine)
46 assert(len(args) == 3)
47 main_objects, tool_objects, partition_combine = args
49 self.setMainObjects(main_objects)
50 self.setToolObjects(tool_objects)
51 self.setPartitionCombine(partition_combine)
56 def setMainObjects(self, main_objects):
57 """Modify base attribute of the feature.
61 self._fillAttribute(self._main_objects, main_objects)
64 def setToolObjects(self, tool_objects):
65 """Modify the to_size, from_size attributes of the feature.
69 self._fillAttribute(self._tool_objects, tool_objects)
72 def setPartitionCombine(self, partition_combine):
73 """Modify planes and offsets attributes of the feature.
77 self._fillAttribute(self._partition_combine, partition_combine)