write_object_model_3d — Writes a 3D object model to a file.
The operator write_object_model_3d writes the 3D object model ObjectModel3D to the file FileName. The object model can be read again with read_object_model_3d, or can be imported into an appropriate CAD program. Please note, that primitives may only be stored in the HALCON format 'om3'. Should it be necessary to store the primitives in another format, the operator sample_object_model_3d has to be called beforehand. However, this results in a transformation of the primitives into 3D points and therefore only corresponds to an approximation of the primitives.
All coordinates are written in meters. If the file is read later using read_object_model_3d, the parameter Scale must be set to 'm' to avoid scaling the data.
The parameter FileType determines the type of the file. The following types are supported by this operator:
HALCON format for object model 3D. Files with this format can be read by read_object_model_3d. The default file extension for this format is 'om3'.
AUTOCAD format. See read_object_model_3d for details about reading this file format. The default file extension for this format is 'dxf'.
Object File Format. This is an ASCII-based format that can hold 3D points and polygons. The default file extension for this format is 'off'.
Polygon File Format (also Stanford Triangle Format). This is a simple format that can hold 3D points, point normals, polygons, color information and point-based extended attributes. HALCON supports the writing of both the ASCII and the binary version of this format. The default file extension for this format is 'ply'.
OBJ file format, also Wavefront OBJ-Format. This is an ASCII-based format that can hold 3D points, polygons, normals, and triangles, which are stored as polygons. The default file extension for this format is 'obj'.
STL file format, also 'Stereolithography format', 'SurfaceTesselationLanguage ', 'StandardTriangulationLanguage', and 'StandardTesselationLanguage'. This format stores triangles and triangle normals. However, as triangle normals are not supported by HALCON 3D object models and point normals (which are, for example, calculated by surface_normals_object_model_3d) are not supported by the STL format, no normals are written to file. If the 3D object model contains polygons, they are converted to triangles before before writing them to disc. If the file type is set to 'stl' or 'stl_binary', the binary version of STL is written while 'stl_ascii' selects the ASCII version. The default file extension for this format is 'stl'.
A set of additional optional parameters can be set. The names and values of the parameters are passed in GenParamName and GenParamValue, respectively. Some of the optional parameters can only be set for a certain file type. The following values for GenParamName are possible:
Invert normals and face orientation before saving the 3D object model. If this value is set to 'true', for the formats 'off', 'ply', 'obj', and 'stl' the orientation of faces (triangles and polygons) is inverted . For formats that support point normals ('ply','obj'), all normals are inverted before writing them to disc. Note that for the types 'om3' and 'dxf' the parameter has no effect.
Value list: 'true', 'false'
Default value: 'false'
Valid for formats: 'off', 'ply', 'obj', 'stl'
Handle of the 3D object model.
Type of the file that is written.
Default value: 'om3'
List of values: 'dxf', 'obj', 'off', 'om3', 'ply', 'ply_binary', 'stl', 'stl_ascii', 'stl_binary'
Name of the file that is written.
File extension: .off, .ply, .dxf, .om3, .obj, .stl
Names of the generic parameters.
Default value: 
List of values: 'invert_normals'
Values of the generic parameters.
Default value: 
Suggested values: 'true', 'false'
The operator write_object_model_3d returns the value 2 (H_MSG_TRUE) if the given parameters are correct and the file can be written. If necessary, an exception will be raised.