Creating Dimension Objects (How to Create a Plug-In)

www.CAD6.com

When implementing import filters or external commands, you will sometimes have to create complex objects that required more than simple geometrical data. A rather common type of complex objects are dimensions. This chapter will show some examples on how to create these types of objects. Dimension objects consist of several types of data: Geometrical data defining the measure, geometrical data defining the dimension line's position, the dimension texts, a description of the font to be used, and the position of the text. Each type of dimension has its special sequence of data blocks required to provide all this data.

 

First, lets create a simple length dimension using standard parameters.

 

C++ Source Code

// Variables required to create a dimension object.

bool          fResult;

MKI_DIMLARGE  cData;

 

// Initialize the variables.

cData.InitLarge();

 

// Create a dimension text object.

MKI_ObjectOpen( MKI_OBJ_DDISTANCE );

MKI_ObjectAddPoint( MKI_DB_POINT_START, -100.0, 0.0 );

MKI_ObjectAddPoint( MKI_DB_POINT_END,   100.0, 0.0 );

MKI_ObjectAddPoint( MKI_DB_POINT_ANY,   0.0, 0.0 );

MKI_ObjectAddPoint( MKI_DB_POINT_ANY,   0.0, 10.0 );

MKI_ObjectAddPoint( MKI_DB_POINT_ANY,   0.0, 0.0 );

MKI_ObjectAddPoint( MKI_DB_POINT_ANY,   0.0, 0.0 );

MKI_ObjectAddPoint( MKI_DB_POINT_ANY,   0.0, 0.0 );

MKI_ObjectAddPoint( MKI_DB_POINT_ANY,   -100.0, 0.0 );

MKI_ObjectAddPoint( MKI_DB_POINT_ANY,   100.0, 0.0 );

MKI_ObjectAddTextShort( L"", false );

MKI_ObjectAddTextShort( L"", true );

MKI_ObjectAddTextShort( L"", false );

MKI_ObjectAddTextShort( L"", false );

MKI_ObjectAddTextShort( L"", false );

MKI_ObjectAddDimLarge( &cData, true );

 

// Insert the text object into the current drawing.

fResult = ( MKI_ObjectFastInsert() != nullptr );

 

This short code sequence will result in a distance dimension that measures the distance between the point (-100.0, 0.0) and (100.0, 0.0). The dimension line's position is determined by the point (0.0, 10.0).

 

For further information about the internal data block structure of the object MKI_OBJ_DDISTANCE, see Object 25 "Distance Dimension".

 

CAD6interface 2025.0 - Copyright 2025 Malz++Kassner® GmbH