[求助]创建多个图层的问题
AcDbObjectId CCreateEnt::CreatLayer (char layername,int nNewColor,int Weight,char linetype)<br/>{<br/>// 获得当前图形的层表<br/>AcDbLayerTable *pLayerTbl;<br/>acdbHostApplicationServices()->workingDatabase()<br/> ->getLayerTable(pLayerTbl, AcDb::kForWrite);<br/><br/>// 创建新的层表记录<br/>AcDbObjectId layerTblRcdId;<br/>AcDbLayerTableRecord *pLayerTblRcd;<br/>pLayerTblRcd = new AcDbLayerTableRecord();<br/>pLayerTblRcd->setName(layername);<br/>AcCmColor color;<br/>color.setColorIndex(nNewColor);<br/>pLayerTblRcd->setColor(color);<br/>AcDb::ineWeight lineWeight =(AcDb::ineWeight)Weight;<br/>pLayerTblRcd->setLineWeight(lineWeight);<br/>AcDbLinetypeTable *pLinetypeTbl;<br/>acdbHostApplicationServices()->workingDatabase()<br/> ->getLinetypeTable(pLinetypeTbl, AcDb::kForWrite);<br/>AcDbObjectId linetypeId;<br/>pLinetypeTbl->getAt(linetype, linetypeId);<br/>pLayerTblRcd->setLinetypeObjectId(linetypeId);<br/><br/>// 将新建的层表记录添加到层表中<br/><br/>pLayerTbl->add(layerTblRcdId, pLayerTblRcd);<br/>pLayerTbl->close();<br/>pLayerTblRcd->close();<br/>return layerTblRcdId;<br/>}<br/><br/><br/>这是 我 编写的 创建图层的 函数,我在调用时如果调用一次 运行可以成功,但当调用2次 或多次的时候 CAD就运行错误,请 高手给解决一下! 谢谢了!<br/>以下我是的调用过程,在下初学者,请多多指教!<br/> char name2[]="02";<br/> char name3[]="03";<br/> char linetype1[]="CENTER";<br/> char linetype2[]="DASHED";<br/> char linetype3[]="Continuous";<br/>CCreateEnt::CreatLayer(name1,1,0,linetype1);<br/> CCreateEnt::CreatLayer(name2,50,0,linetype2);<br/> CCreateEnt::CreatLayer(name3,100,30,linetype3); 补充:设置线宽那句少了一个 l 是我刚才输入时不小心弄的,我程序里不少l <p>不想再调试了</p><p>出错的提示呢?</p> <p>啊 问题已经解决了 是 没有关闭 线型表.... </p><p>谢谢!</p> 这个有点高深,没用过这个。以后再看!
页:
[1]