write_object_model_3dT_write_object_model_3dWriteObjectModel3dWriteObjectModel3dwrite_object_model_3d (Operator)

Name

write_object_model_3dT_write_object_model_3dWriteObjectModel3dWriteObjectModel3dwrite_object_model_3d — Writes a 3D object model to a file.

Signature

write_object_model_3d( : : ObjectModel3D, FileType, FileName, GenParamName, GenParamValue : )

Herror T_write_object_model_3d(const Htuple ObjectModel3D, const Htuple FileType, const Htuple FileName, const Htuple GenParamName, const Htuple GenParamValue)

void WriteObjectModel3d(const HTuple& ObjectModel3D, const HTuple& FileType, const HTuple& FileName, const HTuple& GenParamName, const HTuple& GenParamValue)

void HObjectModel3D::WriteObjectModel3d(const HString& FileType, const HString& FileName, const HTuple& GenParamName, const HTuple& GenParamValue) const

void HObjectModel3D::WriteObjectModel3d(const HString& FileType, const HString& FileName, const HString& GenParamName, const HString& GenParamValue) const

void HObjectModel3D::WriteObjectModel3d(const char* FileType, const char* FileName, const char* GenParamName, const char* GenParamValue) const

void HObjectModel3D::WriteObjectModel3d(const wchar_t* FileType, const wchar_t* FileName, const wchar_t* GenParamName, const wchar_t* GenParamValue) const   ( Windows only)

static void HOperatorSet.WriteObjectModel3d(HTuple objectModel3D, HTuple fileType, HTuple fileName, HTuple genParamName, HTuple genParamValue)

void HObjectModel3D.WriteObjectModel3d(string fileType, string fileName, HTuple genParamName, HTuple genParamValue)

void HObjectModel3D.WriteObjectModel3d(string fileType, string fileName, string genParamName, string genParamValue)

def write_object_model_3d(object_model_3d: HHandle, file_type: str, file_name: str, gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[str, float, int]]) -> None

Description

The operator write_object_model_3dwrite_object_model_3dWriteObjectModel3dWriteObjectModel3dwrite_object_model_3d writes the 3D object model ObjectModel3DObjectModel3DObjectModel3DobjectModel3Dobject_model_3d to the file FileNameFileNameFileNamefileNamefile_name. The object model can be read again with read_object_model_3dread_object_model_3dReadObjectModel3dReadObjectModel3dread_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'"om3""om3""om3""om3". Should it be necessary to store the primitives in another format, the operator sample_object_model_3dsample_object_model_3dSampleObjectModel3dSampleObjectModel3dsample_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_3dread_object_model_3dReadObjectModel3dReadObjectModel3dread_object_model_3d, the parameter Scale must be set to 'm'"m""m""m""m" to avoid scaling the data.

The parameter FileTypeFileTypeFileTypefileTypefile_type determines the type of the file. The following types are supported by this operator:

'om3'"om3""om3""om3""om3":

HALCON format for object model 3D. Files with this format can be read by read_object_model_3dread_object_model_3dReadObjectModel3dReadObjectModel3dread_object_model_3d. The default file extension for this format is 'om3'.

'dxf'"dxf""dxf""dxf""dxf":

AUTOCAD format. See read_object_model_3dread_object_model_3dReadObjectModel3dReadObjectModel3dread_object_model_3d for details about reading this file format. The default file extension for this format is 'dxf'.

'off'"off""off""off""off":

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'.

'ply'"ply""ply""ply""ply",
'ply_binary'"ply_binary""ply_binary""ply_binary""ply_binary":

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'"obj""obj""obj""obj":

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'"stl""stl""stl""stl",
'stl_binary'"stl_binary""stl_binary""stl_binary""stl_binary",
'stl_ascii'"stl_ascii""stl_ascii""stl_ascii""stl_ascii":

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_3dsurface_normals_object_model_3dSurfaceNormalsObjectModel3dSurfaceNormalsObjectModel3dsurface_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'"stl""stl""stl""stl" or 'stl_binary'"stl_binary""stl_binary""stl_binary""stl_binary", the binary version of STL is written while 'stl_ascii'"stl_ascii""stl_ascii""stl_ascii""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 GenParamNameGenParamNameGenParamNamegenParamNamegen_param_name and GenParamValueGenParamValueGenParamValuegenParamValuegen_param_value, respectively. Some of the optional parameters can only be set for a certain file type. The following values for GenParamNameGenParamNameGenParamNamegenParamNamegen_param_name are possible:

'invert_normals'"invert_normals""invert_normals""invert_normals""invert_normals":

Invert normals and face orientation before saving the 3D object model. If this value is set to 'true'"true""true""true""true", for the formats 'off'"off""off""off""off", 'ply'"ply""ply""ply""ply", 'obj'"obj""obj""obj""obj", and 'stl'"stl""stl""stl""stl" the orientation of faces (triangles and polygons) is inverted . For formats that support point normals ('ply'"ply""ply""ply""ply",'obj'"obj""obj""obj""obj"), all normals are inverted before writing them to disc. Note that for the types 'om3'"om3""om3""om3""om3" and 'dxf'"dxf""dxf""dxf""dxf" the parameter has no effect.

Valid for formats: 'off'"off""off""off""off", 'ply'"ply""ply""ply""ply", 'obj'"obj""obj""obj""obj", 'stl'"stl""stl""stl""stl". List of values: 'true'"true""true""true""true", 'false'"false""false""false""false".

Default: 'false'"false""false""false""false".

Execution Information

Parameters

ObjectModel3DObjectModel3DObjectModel3DobjectModel3Dobject_model_3d (input_control)  object_model_3d HObjectModel3D, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Handle of the 3D object model.

FileTypeFileTypeFileTypefileTypefile_type (input_control)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Type of the file that is written.

Default: 'om3' "om3" "om3" "om3" "om3"

List of values: 'dxf'"dxf""dxf""dxf""dxf", 'obj'"obj""obj""obj""obj", 'off'"off""off""off""off", 'om3'"om3""om3""om3""om3", 'ply'"ply""ply""ply""ply", 'ply_binary'"ply_binary""ply_binary""ply_binary""ply_binary", 'stl'"stl""stl""stl""stl", 'stl_ascii'"stl_ascii""stl_ascii""stl_ascii""stl_ascii", 'stl_binary'"stl_binary""stl_binary""stl_binary""stl_binary"

FileNameFileNameFileNamefileNamefile_name (input_control)  filename.write HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Name of the file that is written.

File extension: .off, .ply, .dxf, .om3, .obj, .stl

GenParamNameGenParamNameGenParamNamegenParamNamegen_param_name (input_control)  string(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Names of the generic parameters.

Default: []

List of values: 'invert_normals'"invert_normals""invert_normals""invert_normals""invert_normals"

GenParamValueGenParamValueGenParamValuegenParamValuegen_param_value (input_control)  string(-array) HTupleMaybeSequence[Union[str, float, int]]HTupleHtuple (string / real / integer) (string / double / int / long) (HString / double / Hlong) (char* / double / Hlong)

Values of the generic parameters.

Default: []

Suggested values: 'true'"true""true""true""true", 'false'"false""false""false""false"

Result

The operator write_object_model_3dwrite_object_model_3dWriteObjectModel3dWriteObjectModel3dwrite_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.

Possible Predecessors

read_object_model_3dread_object_model_3dReadObjectModel3dReadObjectModel3dread_object_model_3d, xyz_to_object_model_3dxyz_to_object_model_3dXyzToObjectModel3dXyzToObjectModel3dxyz_to_object_model_3d

Possible Successors

read_object_model_3dread_object_model_3dReadObjectModel3dReadObjectModel3dread_object_model_3d

See also

read_object_model_3dread_object_model_3dReadObjectModel3dReadObjectModel3dread_object_model_3d

Module

3D Metrology