hgfhhw 发表于 2007-8-3 19:49:00

初学者写的两个实现函数,请教问题出在哪里.

<p>我是ARX初学者,用于做毕业论文,写了两个小函数,但尝试编译的时候,没有达到预期的效果,请高手指点,谢谢!</p><p>函数一:</p><p>函数的期望实现目标:新建一个图层,并同时确实线型和图层颜色。</p><p>void CreateNewLayer(const ACHAR* pNewLayerName,const ACHAR* pLinetypeName,int colorNo)<br/>{<br/>&nbsp;AcDbDatabase *pCurDb;<br/>&nbsp;AcDbLayerTable *pLayerTable;<br/>&nbsp;pCurDb=acdbHostApplicationServices()-&gt;workingDatabase();<br/>&nbsp;pCurDb-&gt;getLayerTable(pLayerTable,AcDb::kForWrite);<br/>&nbsp;&nbsp;&nbsp; if (pLayerTable-&gt;has(pNewLayerName))<br/>&nbsp;{<br/>&nbsp;&nbsp;pLayerTable-&gt;close();<br/>&nbsp;&nbsp;return&nbsp; ;<br/>&nbsp;}<br/>&nbsp;&nbsp;&nbsp; AcDbLayerTableRecord *pLayerTblRecord = new AcDbLayerTableRecord;<br/>&nbsp;pLayerTblRecord-&gt;setName(pNewLayerName);</p><p>&nbsp;AcCmColor color;<br/>&nbsp;color.setColorIndex(colorNo); <br/>&nbsp;pLayerTblRecord-&gt;setColor(color);</p><p>&nbsp;&nbsp;&nbsp; AcDbLinetypeTable *pLinetypeTbl;<br/>&nbsp;&nbsp;&nbsp; pCurDb-&gt;getLinetypeTable(pLinetypeTbl,AcDb::kForWrite);<br/>&nbsp;AcDbObjectId ltypeObjId;<br/>&nbsp;pLinetypeTbl-&gt;getAt(pLinetypeName,ltypeObjId);<br/>&nbsp;pLayerTblRecord-&gt;setLinetypeObjectId(ltypeObjId);<br/>&nbsp;pLayerTable-&gt;add(pLayerTblRecord);</p><p>&nbsp;pLinetypeTbl-&gt;close();<br/>&nbsp;pLayerTable-&gt;close();<br/>&nbsp;pLayerTblRecord-&gt;close();<br/>&nbsp;&nbsp;&nbsp; return ;<br/>&nbsp;<br/>} </p><p>函数二:</p><p>函数的期望实现目标:将图层转换到期望的图层再进行绘图编辑。</p><p>void CCreateEnt::ChangeLayer(const ACHAR* LayerName)<br/>{<br/>&nbsp;AcDbLayerTable *pLayerTbl;<br/>&nbsp;acdbHostApplicationServices()-&gt;workingDatabase()<br/>&nbsp;&nbsp;-&gt;getLayerTable(pLayerTbl, AcDb::kForRead);<br/>&nbsp;//是否已经包含指定的层表记录<br/>&nbsp;&nbsp;&nbsp; if (pLayerTbl-&gt;has(LayerName))<br/>&nbsp;&nbsp;&nbsp;&nbsp; {<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pLayerTbl-&gt;close();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br/>&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;AcDbLayerTableRecord *pLayerTblRcd;<br/>&nbsp;pLayerTbl-&gt;getAt(LayerName,pLayerTblRcd,AcDb::kForWrite);<br/>&nbsp;//acdbHostApplicationServices()-&gt;workingDatabase()-&gt;setClayer(layerTblRcdId);</p><p>&nbsp;&nbsp;&nbsp; pLayerTbl-&gt;close();<br/>&nbsp;pLayerTblRcd-&gt;close();<br/>&nbsp;return;<br/>}</p><p></p><p>请大侠指教一下问题出在哪里,谢谢!!</p><p><br/></p>

hgfhhw 发表于 2007-8-3 23:15:00

自己已经解决
页: [1]
查看完整版本: 初学者写的两个实现函数,请教问题出在哪里.