帮助中的例子:
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; } |