You can create anonymous blocks by calls to acdbEntMake(). To do so, you must open the block with a name whose first character is * and a block typeflag (group 70) whose low-order bit is set to 1. AutoCAD assigns the new anonymous block a name; characters in the name string that follow the * are often ignored. You then create the anonymous block the way you would create a regular block, except that it is more important to call acedGetInput(). Because the name is generated by AutoCAD, your program has no other way of knowing the name of the new block.
The following code begins an anonymous block, ends it, and retrieves its name.
int status; struct resbuf *entlist; ads_point basept; char newblkname[20]; ads_point pnt1 = ( 0.0, 0.0, 0.0); entlist = acutBuildList( RTDXF0, "BLOCK", 2, "*ANON", // Only the '*' matters. 10, "1", // No other flags are set. 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 start anonymous block\n"); return BAD; } // Add entities to the block by more acdbEntMake calls. . . . entlist = acutBuildList(RTDXF0, "ENDBLK", 0 ); if (entlist == NULL) { acdbFail("Unable to create result buffer list\n"); return BAD; } status = acdbEntMake(entlist); acutRelRb(entlist); // Release acdbEntMake buffer. if (status != RTKWORD) { acdbFail("Unable to close anonymous block\n"); return BAD; } status = acedGetInput(newblkname); if (status != RTNORM) { acdbFail("Anonymous block not created\n"); return BAD; }
To reference an anonymous block, create an insert entity with acdbEntMake(). (You cannot pass an anonymous block to the INSERT command.)
Continuing the previous example, the following code fragment inserts the anonymous block at (0,0).
basept[X] = basept[Y] = basept[Z] = 0.0; entlist = acutBuildList( RTDXF0, "INSERT", 2, newblkname, // From acedGetInput 10, basept, 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 insert anonymous block\n"); return BAD; }