Creating Groups (How to Create a Plug-In)

www.CAD6.com

When creating multiple objects during the execution of one command, it will often be useful to store these objects inside a group. A group is a special form of block that is stored directly in the drawing.

 

As a simple example, let's create a group that contains two ing lines. Groups may, however, also contain more complex objects and even instances of other groups or blocks.

 

C++ Source Code

bool  fResult = true;

 

MKI_UndoInitProcess();

 

// Open a group. While a group is open, all objects and

// instances created will be added to that group.

MKI_GroupOpen();

 

// Create the first object to be added to the group.

if( fResult )

{

  MKI_ObjectOpen( MKI_OBJ_LINE );

  MKI_ObjectAddPoint( MKI_DB_POINT_START, -148.5, -105.0 );

  MKI_ObjectAddPoint( MKI_DB_POINT_END,    148.5,  105.0 );

 

  if( !MKI_ObjectFastInsert() )

    fResult = false;

}

 

// Create the second object to be added to the group.

if( fResult )

{

  MKI_ObjectOpen( MKI_OBJ_LINE );

  MKI_ObjectAddPoint( MKI_DB_POINT_START,  148.5, -105.0 );

  MKI_ObjectAddPoint( MKI_DB_POINT_END,   -148.5,  105.0 );

 

  if( !MKI_ObjectFastInsert() )

    fResult = false;

}

 

// Close the group, insert it into the drawing and

// create an instance that references that group.

if( fResult )

{

  if( !MKI_GroupFastInsert( true, nullptr ) )

    fResult = false;

}

 

// Update the internal links (necessary if groups or blocks

// have been created) and draw the newly created objects.

if( fResult )

{

  MKI_UndoFinishProcess();

  MKI_UndoUpdateLinks();

  MKI_DrawNewObjects();

}

else

  MKI_UndoCancelProcess();

 

CAD6interface 2025.0 - Copyright 2025 Malz++Kassner® GmbH