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 class for Import feature.
21 Import(feature) -> feature interface without initialization
22 Import(feature, file_path) ->
23 feature interface initialized from arguments:
24 - file_path -- path to the imported file
27 def __init__(self, feature, *args):
28 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
29 Interface.__init__(self, feature)
30 assert(self._feature.getKind() == "Import")
32 self._file_path = self._feature.data().string("file_path")
34 assert(self._file_path)
39 assert(len(args) == 1)
40 self.setFilePath(args[0])
45 def setFilePath(self, file_path):
46 """Modify file path attribute of the feature.
50 self._fill_attribute(self._file_path, file_path)
54 def exportToFile(part, *args):
55 """Add an Export feature to the Part and return Export.
57 Pass all args to Export __init__ function.
59 feature = part.addFeature("Export")
60 return Export(feature, *args)
63 class Export(Interface):
64 """Interface class for Export feature.
66 Export(feature) -> feature interface without initialization
67 Export(feature, file_path, file_format, selection_list) ->
68 feature interface initialized from arguments:
69 - file_path -- path to the exported file
70 - file_format -- format of to the exported file
71 - selection_list -- objects to export
74 def __init__(self, feature, *args):
75 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
76 Interface.__init__(self, feature)
77 assert(self._feature.getKind() == "Export")
79 self._file_path = self._feature.data().string("file_path")
80 self._file_format = self._feature.data().string("file_format")
81 self._objects = self._feature.data().selectionList("selection_list")
83 assert(self._file_path)
84 assert(self._file_format)
90 assert(len(args) == 3)
91 self.setFilePath(args[0])
92 self.setFileFormat(args[1])
93 self.setObjects(args[2])
98 def setFilePath(self, file_path):
99 """Modify file path attribute of the feature.
103 self._fill_attribute(self._file_path, file_path)
106 def setFileFormat(self, file_format):
107 """Modify file path attribute of the feature.
111 self._fill_attribute(self._file_format, file_format)
114 def setObjects(self, objects):
115 """Modify file path attribute of the feature.
119 self._fill_attribute(self._objects, object)