- 积分
- 1087
- 明经币
- 个
- 注册时间
- 2004-9-15
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
已知“图层1”存在,如何修改名称为“图层2”,我简单写了个命令,执行就死机,不知道什么情况?请各位不吝赐教。
// - OperateLayer._ChangeLayer command (do not rename)
static void OperateLayer_ChangeLayer(void)
{
// Add your code for command OperateLayer._ChangeLayer here
AcDbLayerTable *pLayerTbl;
AcDbObjectId layerId;
AcDbLayerTableRecord *pLayerRecord;
ACHAR *layerName=new ACHAR[100];
if (acdbCurDwg()->getLayerTable(pLayerTbl,AcDb::kForRead)!=Acad::eOk)
{
pLayerTbl->close();
ads_printf(_T("\n错误:打开层表出错! \n"));
return;
}
//获取层表记录
layerName=_T("图层1");
if (pLayerTbl->getAt(layerName,pLayerRecord,AcDb::kForWrite) != Acad::eOk)
{
pLayerTbl->close();
ads_printf(_T("\n错误:获取层表记录出错! \n"));
return;
}
//修改层名
layerName=_T("图层2");
pLayerRecord->setName(layerName);
//获取层表记录ID
if (pLayerTbl->getAt(layerName,layerId,false) != Acad::eOk)
{
pLayerTbl->close();
ads_printf(_T("\n错误:获取层表记录出错! \n"));
return;
}
//设置当前层
acdbCurDwg()->setClayer(layerId);
delete layerName;
pLayerTbl->close();
pLayerRecord->close();
return;
}
|
|