Hide menu
Loading...
Searching...
No Matches
Import and Export

The full list of supported formats can be found here:

Import

When reading a file, the result is converted into a common data model that provides format-neutral data representation and access API.

Reading files

ModelData_ModelReader is the primary class for reading files. The usage is simple: one just has to call a single function with the path to the file that should be read and the target ModelData_Model instance.

The data model object will be populated with the contents imported from the file being read. The model is not cleaned up before conversion, therefore multiple files can be accumulated in the same model.

import mtk.MTKCore as mtk
aModel = mtk.ModelData_Model()
aReader = mtk.ModelData_ModelReader()
if not aReader.Read(mtk.UTF16String("myfile.stp"), aModel):
#error during reading the file
Definition MTKCore.py:1

Parameters

Reader parameters are controlled by ModelData_ModelReaderParameters class and can be set using ModelData_ModelReader.SetParameters() method.

Parameter Default value
ModelData_ModelReaderParameters.ReadPMI() false
ModelData_ModelReaderParameters.ReadDrawing() false
ModelData_ModelReaderParameters.EnableAnalyticalRecognition() true

Export

To export a model, use the ModelData_ModelWriter class. This class writes the contents of the model to a file, selecting the format based on the file extension.

import mtk.MTKCore as mtk
aModel = mtk.ModelData_Model()
# Populate the model...
aModelWriter = mtk.ModelData_ModelWriter()
if not aModelWriter.Write(aModel, mtk.UTF16String("output_model.step")):
print("\nERROR: Failed to export")

Parameters

Writer parameters are controlled by ModelData_ModelWriterParameters and can be set using ModelData_ModelWriter.SetParameters() .