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.
12 .. function:: addImport(part, file_path)
15 part (ModelAPI_Document): part document
16 file_path (string): path to the imported file
22 feature = part.addFeature("Import")
23 return Import(feature, *args)
26 class Import(Interface):
27 """Interface class for Import feature.
29 .. function:: Import(feature)
31 Create interface for the feature without initialization.
33 .. function:: Import(feature, file_path)
35 Create interface for the feature and initialize the feature with arguments.
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() == "Import")
43 self._file_path = self._feature.data().string("file_path")
45 assert(self._file_path)
50 assert(len(args) == 1)
51 self.setFilePath(args[0])
56 def setFilePath(self, file_path):
57 """Modify file path attribute of the feature.
61 self._fillAttribute(self._file_path, file_path)
65 def exportToFile(part, *args):
66 """Perform export from the Part to file.
68 .. function:: exportToFile(part, file_path, file_format, selection_list)
71 part (ModelAPI_Document): part document
72 file_path (string): path to the exported file
73 file_format (string): format of to the exported file
74 selection_list (list of Selection): objects to export
80 feature = part.addFeature("Export")
81 return Export(feature, *args)
84 class Export(Interface):
85 """Interface class for Export feature.
87 .. function:: Export(feature)
89 Create interface for the feature without initialization.
91 .. function:: Export(feature, file_path, file_format, selection_list)
93 Create interface for the feature and initialize the feature with arguments.
96 def __init__(self, feature, *args):
97 """x.__init__(...) initializes x; see x.__class__.__doc__ for signature"""
98 Interface.__init__(self, feature)
99 assert(self._feature.getKind() == "Export")
101 self._file_path = self._feature.data().string("file_path")
102 self._file_format = self._feature.data().string("file_format")
103 self._objects = self._feature.data().selectionList("selection_list")
105 assert(self._file_path)
106 assert(self._file_format)
107 assert(self._objects)
112 assert(len(args) == 3)
113 self.setFilePath(args[0])
114 self.setFileFormat(args[1])
115 self.setObjects(args[2])
120 def setFilePath(self, file_path):
121 """Modify file path attribute of the feature.
125 self._fillAttribute(self._file_path, file_path)
128 def setFileFormat(self, file_format):
129 """Modify file path attribute of the feature.
133 self._fillAttribute(self._file_format, file_format)
136 def setObjects(self, objects):
137 """Modify file path attribute of the feature.
141 self._fillAttribute(self._objects, object)