2 Author: Sergey Pokhodenko
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
6 from model.roots import Interface
9 def addImport(part, *args):
10 """Add an Import feature to the Part and return Import.
12 Pass all args to Import __init__ function.
14 feature = part.addFeature("Import")
15 return Import(feature, *args)
18 class Import(Interface):
19 """Interface on an Import feature."""
21 def __init__(self, feature, *args):
22 """Initialize an Import feature with given parameters.
24 Expected arguments for all modes:
25 feature -- an Import feature
27 For initialization (expect 1 argument):
28 file_path -- path to the imported file
30 Interface.__init__(self, feature)
31 assert(self._feature.getKind() == "Import")
33 self._file_path = self._feature.data().string("file_path")
38 assert(len(args) == 1)
39 self.setFilePath(*args)
42 def setFilePath(self, file_path):
43 """Modify file path attribute of the feature.
47 self._fill_attribute(self._file_path, file_path)
51 def addExport(part, *args):
52 """Add an Export feature to the Part and return Export.
54 Pass all args to Export __init__ function.
56 feature = part.addFeature("Export")
57 return Export(feature, *args)
60 class Export(Interface):
61 """Interface on an Export feature."""
63 def __init__(self, feature, *args):
64 """Initialize an Export feature with given parameters.
66 Expected arguments for all modes:
67 feature -- an Export feature
69 For initialization (expect 3 argument):
70 file_path -- path to the exported file
71 file_format -- format of to the exported file
72 objects -- objects to export
74 Interface.__init__(self, feature)
75 assert(self._feature.getKind() == "Export")
77 self._file_path = self._feature.data().string("file_path")
78 self._file_format = self._feature.data().string("file_format")
79 self._objects = self._feature.data().selectionList("selection_list")
84 assert(len(args) == 3)
85 self.setFilePath(args[0])
86 self.setFileFormat(args[1])
87 self.setObjects(args[2])
90 def setFilePath(self, file_path):
91 """Modify file path attribute of the feature.
95 self._fill_attribute(self._file_path, file_path)
98 def setFileFormat(self, file_format):
99 """Modify file path attribute of the feature.
103 self._fill_attribute(self._file_format, file_format)
106 def setObjects(self, objects):
107 """Modify file path attribute of the feature.
111 self._fill_attribute(self._objects, object)