- 积分
- 3855
- 明经币
- 个
- 注册时间
- 2003-12-18
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
我在网上抄了一段代码放到工程里, 编译的时候出现"error C2065: 'layer_tc' : undeclared identifier"代码如下:- //yfy2003
- //图层合并
- //将一个图层的所有对象转移到另一个图层,并删除原图层。 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;
- }
复制代码 就是红色字那里有问题,这个指针前面没有出现过.请问该怎么改啊.应该释放哪个指针变量. |
|