Complex Entities

A complex entity (a polyline or block) must be created by multiple calls to acdbEntMake(), using a separate call for each subentity. When acdbEntMake() first receives an initial component for a complex entity, it creates a temporary file in which to gather the definition data (and extended data, if present). Each subsequent acdbEntMake() call appends the new subentity to the file. When the definition of the complex entity is complete (that is, when acdbEntMake() receives an appropriate Seqend or Endblk subentity), the entity is checked for consistency, and if valid, it is added to the drawing. The file is deleted when the complex entity is complete or when its creation is canceled.

The following example contains five calls to acdbEntMake() that create a single complex entity, a polyline. The polyline has a linetype of DASHED and a color of BLUE. It has three vertices located at coordinates (1,1,0), (4,6,0), and (3,2,0). All other optional definition data assume default values.

int status; 
struct resbuf *entlist, result; 
ads_point newpt; 
entlist = acutBuildList(
    RTDXF0, "POLYLINE",// Entity type 
    62, 5, // Color (blue) 
    6, "dashed",// Linetype 
    66, 1, // Vertices follow.
    0); 
if (entlist == NULL) { 
    acdbFail("Unable to create result buffer list\n"); 
    return BAD; 
} 
status = acdbEntMake(entlist); 
acutRelRb(entlist); // Release acdbEntMake() buffer.
if (status != RTNORM) { 
    acutPrintf ("%d",status);
    acedGetVar ("ERRNO", &result);
    acutPrintf ("ERRNO == %d, result.resval.rint);
    acdbFail("Unable to start polyline\n"); 
    return BAD; 
} 
newpt[X] = 1.0; 
newpt[Y] = 1.0; 
newpt[Z] = 0.0; // The polyline is planar 
entlist = acutBuildList(
    RTDXF0, "VERTEX", // Entity type 
    62, 5, // Color (blue)
    6, "dashed", // Linetype 
    10, newpt, // Start point 
    0); 
if (entlist == NULL) { 
    acdbFail("Unable to create result buffer list\n"); 
    return BAD; 
} 
status = acdbEntMake(entlist); 
acutRelRb(entlist); // Release acdbEntMake() buffer.
if (status != RTNORM) { 
    acdbFail("Unable to add polyline vertex\n"); 
    return BAD; 
} 
newpt[X] = 4.0; 
newpt[Y] = 6.0; 
entlist = acutBuildList(
    RTDXF0, "VERTEX", // Entity type 
    62, 5, // Color (blue)
    6, "dashed", // Linetype
    10, newpt, // Second point 
    0); 
if (entlist == NULL) { 
    acdbFail("Unable to create result buffer list\n"); 
    return BAD; 
} 
status = acdbEntMake(entlist); 
acutRelRb(entlist); // Release acdbEntMake() buffer.
if (status != RTNORM) { 
    acdbFail("Unable to add polyline vertex\n"); 
    return BAD; 
} 
newpt[X] = 3.0; 
newpt[Y] = 2.0; 
entlist = acutBuildList(
    RTDXF0, "VERTEX", // Entity type 
    62, 5, // Color (blue)
    6, "dashed", // Linetype
    10, newpt, // Third point 
    0); 
if (entlist == NULL) { 
    acdbFail("Unable to create result buffer list\n"); 
    return BAD; 
} 
status = acdbEntMake(entlist); 
acutRelRb(entlist); // Release acdbEntMake() buffer.
if (status != RTNORM) { 
    acdbFail("Unable to add polyline vertex\n"); 
    return BAD; 
} 
entlist = acutBuildList(
    RTDXF0, "SEQEND", // Sequence end 
    62, 5, // Color (blue)
    6, "dashed", // Linetype
    0); 
if (entlist == NULL) { 
    acdbFail("Unable to create result buffer list\n"); 
    return BAD; 
} 
status = acdbEntMake(entlist); 
acutRelRb(entlist); // Release acdbEntMake() buffer.
if (status != RTNORM) { 
    acdbFail("Unable to complete polyline\n"); 
    return BAD; 
} 

Creating a block is similar, except that when acdbEntMake() successfully creates the Endblk entity, it returns a value of RTKWORD. You can verify the name of the new block by a call to acedGetInput().