]> SALOME platform Git repositories - modules/shaper.git/blob - src/PythonAPI/model/features/group.py
Salome HOME
68567bd2b99668d15dd5a4e8943093daab71c2f0
[modules/shaper.git] / src / PythonAPI / model / features / group.py
1 """Group Interface
2 Author: Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
4 """
5
6 from model.roots import Interface
7
8
9 def addGroup(part, *args):
10     """Add a Group feature to the Part.
11
12     .. function:: addGroup(part, group_list)
13
14     Args:
15         part (ModelAPI_Document): part document
16         group_list (list of Selection): list of objects
17
18     Returns:
19         Group: group object
20     """
21     assert(args)
22     feature = part.addFeature("Group")
23     return Group(feature, *args)
24
25
26 class Group(Interface):
27     """Interface class for Group feature.
28
29     .. function:: Group(feature)
30
31         Create interface for the feature without initialization.
32
33     .. function:: Group(feature, group_list)
34
35         Create interface for the feature and initialize the feature with arguments.
36     """
37
38     def __init__(self, feature, *args):
39         """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
40         Interface.__init__(self, feature)
41         assert(self._feature.getKind() == "Group")
42
43         self._group_list = self._feature.data().selectionList("group_list")
44
45         assert(self._group_list)
46
47         if not args:
48             return
49
50         assert(len(args) == 1)
51         self.setGroupList(args[0])
52
53         self.execute()
54         pass
55
56     def setGroupList(self, main_objects):
57         """Modify group_list attribute of the feature.
58
59         See __init__.
60         """
61         self._fillAttribute(self._group_list, group_list)
62         pass