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")
35 assert(self._file_path)
40 assert(len(args) == 1)
41 self.setFilePath(args[0])
46 def setFilePath(self, file_path):
47 """Modify file path attribute of the feature.
51 self._fill_attribute(self._file_path, file_path)
55 def exportToFile(part, *args):
56 """Add an Export feature to the Part and return Export.
58 Pass all args to Export __init__ function.
60 feature = part.addFeature("Export")
61 return Export(feature, *args)
64 class Export(Interface):
65 """Interface on an Export feature."""
67 def __init__(self, feature, *args):
68 """Initialize an Export feature with given parameters.
70 Expected arguments for all modes:
71 feature -- an Export feature
73 For initialization (expect 3 argument):
74 file_path -- path to the exported file
75 file_format -- format of to the exported file
76 objects -- objects to export
78 Interface.__init__(self, feature)
79 assert(self._feature.getKind() == "Export")
81 self._file_path = self._feature.data().string("file_path")
82 self._file_format = self._feature.data().string("file_format")
83 self._objects = self._feature.data().selectionList("selection_list")
85 assert(self._file_path)
86 assert(self._file_format)
92 assert(len(args) == 3)
93 self.setFilePath(args[0])
94 self.setFileFormat(args[1])
95 self.setObjects(args[2])
100 def setFilePath(self, file_path):
101 """Modify file path attribute of the feature.
105 self._fill_attribute(self._file_path, file_path)
108 def setFileFormat(self, file_format):
109 """Modify file path attribute of the feature.
113 self._fill_attribute(self._file_format, file_format)
116 def setObjects(self, objects):
117 """Modify file path attribute of the feature.
121 self._fill_attribute(self._objects, object)