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.

using cadex;
ModelData.Model aModel = new ModelData.Model();
ModelData.ModelReader aReader = new ModelData.ModelReader();
if (!aReader.Read(new UTF16String("myfile.stp"), aModel))
{
//error during reading the file
}
Provides MTK data model.
Definition Model.cs:30
Reads supported formats, see Import section.
Definition ModelReader.cs:17
bool Read(cadex.UTF16String theFilePath, cadex.ModelData.Model theModel)
Reads the file at the specified path into the specified model.
Definition ModelReader.cs:86
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition UTF16String.cs:17
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition BaseObject.cs:12

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 in the specified format.

var aModel = new ModelData.Model();
// Populate the model...
var aWriter = new ModelData.ModelWriter();
\code{.csharp}
if (!aWriter.Write(aModel, "output_model.mtk"))
{
Console.WriteLine($"\nERROR: Failed to export");
}