ship120 发表于 2009-2-18 15:23:00

[求助]创建多个图层的问题

AcDbObjectId CCreateEnt::CreatLayer (char layername,int nNewColor,int Weight,char linetype)<br/>{<br/>// 获得当前图形的层表<br/>AcDbLayerTable *pLayerTbl;<br/>acdbHostApplicationServices()-&gt;workingDatabase()<br/>&nbsp;&nbsp;-&gt;getLayerTable(pLayerTbl, AcDb::kForWrite);<br/><br/>// 创建新的层表记录<br/>AcDbObjectId layerTblRcdId;<br/>AcDbLayerTableRecord *pLayerTblRcd;<br/>pLayerTblRcd = new AcDbLayerTableRecord();<br/>pLayerTblRcd-&gt;setName(layername);<br/>AcCmColor color;<br/>color.setColorIndex(nNewColor);<br/>pLayerTblRcd-&gt;setColor(color);<br/>AcDb::ineWeight lineWeight =(AcDb::ineWeight)Weight;<br/>pLayerTblRcd-&gt;setLineWeight(lineWeight);<br/>AcDbLinetypeTable *pLinetypeTbl;<br/>acdbHostApplicationServices()-&gt;workingDatabase()<br/>&nbsp;&nbsp;-&gt;getLinetypeTable(pLinetypeTbl, AcDb::kForWrite);<br/>AcDbObjectId linetypeId;<br/>pLinetypeTbl-&gt;getAt(linetype, linetypeId);<br/>pLayerTblRcd-&gt;setLinetypeObjectId(linetypeId);<br/><br/>// 将新建的层表记录添加到层表中<br/><br/>pLayerTbl-&gt;add(layerTblRcdId, pLayerTblRcd);<br/>pLayerTbl-&gt;close();<br/>pLayerTblRcd-&gt;close();<br/>return layerTblRcdId;<br/>}<br/><br/><br/>这是 我 编写的 创建图层的 函数,我在调用时如果调用一次 运行可以成功,但当调用2次 或多次的时候 CAD就运行错误,请 高手给解决一下!&nbsp;&nbsp;谢谢了!<br/>以下我是的调用过程,在下初学者,请多多指教!<br/>&nbsp;&nbsp;char name2[]="02";<br/>&nbsp;&nbsp;char name3[]="03";<br/>&nbsp;&nbsp;char linetype1[]="CENTER";<br/>&nbsp;&nbsp;char linetype2[]="DASHED";<br/>&nbsp;&nbsp;char linetype3[]="Continuous";<br/>CCreateEnt::CreatLayer(name1,1,0,linetype1);<br/>&nbsp;&nbsp;CCreateEnt::CreatLayer(name2,50,0,linetype2);<br/>&nbsp;&nbsp;CCreateEnt::CreatLayer(name3,100,30,linetype3);

ship120 发表于 2009-2-18 16:47:00

补充:设置线宽那句少了一个 l 是我刚才输入时不小心弄的,我程序里不少l

luowy 发表于 2009-2-18 17:41:00

<p>不想再调试了</p><p>出错的提示呢?</p>

ship120 发表于 2009-2-19 12:23:00

<p>啊 问题已经解决了&nbsp;&nbsp; 是 没有关闭 线型表....&nbsp; </p><p>谢谢!</p>

elsa0918 发表于 2012-2-29 23:56:01

这个有点高深,没用过这个。以后再看
页: [1]
查看完整版本: [求助]创建多个图层的问题