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)
44 def setFilePath(self, file_path):
45 """Modify file path attribute of the feature.
49 self._fill_attribute(self._file_path, file_path)
53 def exportToFile(part, *args):
54 """Add an Export feature to the Part and return Export.
56 Pass all args to Export __init__ function.
58 feature = part.addFeature("Export")
59 return Export(feature, *args)
62 class Export(Interface):
63 """Interface on an Export feature."""
65 def __init__(self, feature, *args):
66 """Initialize an Export feature with given parameters.
68 Expected arguments for all modes:
69 feature -- an Export feature
71 For initialization (expect 3 argument):
72 file_path -- path to the exported file
73 file_format -- format of to the exported file
74 objects -- objects to export
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])
96 def setFilePath(self, file_path):
97 """Modify file path attribute of the feature.
101 self._fill_attribute(self._file_path, file_path)
104 def setFileFormat(self, file_format):
105 """Modify file path attribute of the feature.
109 self._fill_attribute(self._file_format, file_format)
112 def setObjects(self, objects):
113 """Modify file path attribute of the feature.
117 self._fill_attribute(self._objects, object)