[原创]图层合并
本帖最后由 作者 于 2004-5-19 20:23:29 编辑将一个图层的所有对象转移到另一个图层,并删除原图层。AcDbObjectId eId;
AcDbObject *pObj;
AcDbEntity *pE;ads_name ss;
ads_name ent;
ads_point pt;
long len;
char * layer_tc1;
char * layer_tc2;
struct resbuf eb;
struct resbuf blc;
int rc = acedEntSel("\n选择被合并图层实体:",ent,pt);
switch(rc)
{
case RTERROR :
acutPrintf("\n未选中实体! ");
break;case RTCAN :
acutPrintf("\n取消! ");
break;case RTNORM :
acdbGetObjectId(eId,ent);
acdbOpenObject(pE, eId, AcDb::kForRead, false);
layer_tc1 = pE->layer();//查询实体所在的图层
pE->close(); int rcc = acedEntSel("\n选择合并图层实体:",ent,pt);
switch(rcc)
{
case RTERROR :
acutPrintf("\n未选中实体! ");
break; case RTCAN :
acutPrintf("\n取消! ");
break; case RTNORM :
acdbGetObjectId(eId,ent);
acdbOpenObject(pE, eId, AcDb::kForRead, false);
layer_tc2 = pE->layer();
pE->close(); eb.restype = 8;//层名
eb.resval.rstring = layer_tc1;
eb.rbnext = NULL;
acedSSGet("X",NULL,NULL,&eb,ss);
free(eb.resval.rstring); acedSSLength(ss,&len);
for(int i=0; i<len; i++)
{
acedSSName(ss,i,ent);
acdbGetObjectId(eId,ent);
acdbOpenObject(pE, eId, AcDb::kForWrite, false);
pE->setLayer(layer_tc2);
pE->close();
}
acedSSFree(ss); blc.restype = RTSTR;
blc.resval.rstring = "0";
acedSetVar("CLAYER",&blc);//设置当前图层为0层
AcDbLayerTable * pLayerTbl;//定义层表指针
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTbl, AcDb::kForWrite);
AcDbLayerTableRecord * pLayerTblRcd; //定义层表记录指针
if ( Acad::eOk == pLayerTbl->getAt(layer_tc1 , pLayerTblRcd , AcDb::kForWrite))
{
pLayerTblRcd->erase(true);//删除图层
}
pLayerTblRcd->close();
pLayerTbl->close();
free(layer_tc2);
break;
}
free(layer_tc);
break;
}
Now laymrg has been built-in command. Thanks for sharing ^^ 要是能直接在图层特性管理器对话框操作就更好了 感谢楼主分享 下载试试! 为什么这么烦琐,可能是我看不明白吧!选中一层所有的对象,往另一层一放,在purge不完事了哈哈见笑! 就是
用LISP写出来,就这么简单
(defun test(O_Lay D_Lay)<BR> (command "_.change" (ssget "x" (list (cons 8 O_Lay))) "" "p" "la" D_Lay "")<BR> (command "_.purge" "la" O_Lay "n")<BR>) liub1979发表于2004-5-20 19:24:00static/image/common/back.gif为什么这么烦琐,可能是我看不明白吧!选中一层所有的对象,往另一层一放,在purge不完事了哈哈见笑!
<BR>图层和实体太多了就不好办了!
还是用程序比较好。
好象是等高线吧!你的程序咋用,简单的说明一下 : ) "因为不象3楼那么好懂" 如果图层锁定了,能起作用吗? 学习了,谢谢 3楼的程序非常简洁,高手! 能否编写成一个小插件 使用 什么东西啊。
页:
[1]
2