您可以通过调用 to 来创建匿名块。为此,必须使用第一个字符的名称打开块,以及低阶位设置为 1 的块类型标志(组 70)。AutoCAD 为新的匿名块分配一个名称;名称字符串后面的字符经常被忽略。然后,您可以像创建常规块一样创建匿名块,只是调用它更重要。由于名称是由 AutoCAD 生成的,因此程序无法知道新块的名称。acdbEntMake()**acedGetInput() 以下代码开始一个匿名块,结束它,并检索其名称。 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; } 要引用匿名块,请创建插入实体。(不能将匿名块传递给 INSERT 命令。acdbEntMake() 继续前面的示例,以下代码片段在 (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; } |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:07
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.