xhsd 发表于 2010-5-21 23:44:00

[求助]新建图形数据库中创建图层问题--困扰我好久了,跪求高手指点

<strong>我新建一个图层,然后添加到后台一个新建的图形数据库中(此处必须是后台新建的数据库),并保存为test2.dwg,但是打开test2.dwg文件后,新建的图层一直没有创建成功。</strong><div>&nbsp;</div><div><strong><font face="Times New Roman" color="#000000" size="3">void createNewLayer(AcDbDatabase *pDb) <br/>{ </font></strong></div><div><strong><font face="Times New Roman" color="#000000" size="3">AcDbDatabase *&nbsp; pCurDb&nbsp; =&nbsp; pDb;</font></strong></div><strong><font face="Times New Roman" size="3"><div><br/><font color="#000000">AcDbLayerTable *pLayerTable; <br/>pCurDb&nbsp; =&nbsp; acdbHostApplicationServices()-&gt;workingDatabase() -&gt;getSymbolTable(pLayerTable, AcDb::kForWrite); <br/>&nbsp;<br/>AcDbLayerTableRecord *pLayerTableRecord = new AcDbLayerTableRecord; <br/>pLayerTableRecord-&gt;setName("ASDK_MYLAYER"); <br/>// 如果没有指定层的其他属性,就使用缺省值 <br/>pLayerTable-&gt;add(pLayerTableRecord); <br/>pLayerTable-&gt;close(); <br/>pLayerTableRecord-&gt;close(); <br/>} <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>void createDwg2(pDb)<br/>{<br/>AcDbDatabase *pDb = new AcDbDatabase();</font></div><div></div></font></strong>&nbsp; <div><strong><font face="Times New Roman" color="#000000" size="3">createNewLayer();</font></strong></div><div><strong><font face="Times New Roman" size="3"></font></strong>&nbsp;</div><div><strong><font face="Times New Roman" color="#000000" size="3">pDb-&gt;saveAs("c:\\test2.dwg");<br/>delete pDb;<br/>}</font></strong></div><div><strong><font face="Times New Roman" color="#000000" size="3"></font></strong>&nbsp;</div><div class="O" vshape="_x0000_s1026"><div style="mso-line-spacing: '150 20 0'; mso-margin-left-alt: 216;"><b><font size="3"><div><font color="#000000">是不是该段代码有问题, <strong><font face="Times New Roman" size="3">pCurDb&nbsp; =&nbsp;<u> acdbHostApplicationServices()-&gt;workingDatabase() </u>-&gt;getSymbolTable(pLayerTable, AcDb::kForWrite); </font></strong></font></div><div><strong><font face="Times New Roman" size="3"></font></strong><font color="#000000">此处是打开的是当前的数据库,但是我从书中和网络上看到的新建图层都是这样操作的,不知该如何更改</font></div></font></b></div></div>

rongyifei 发表于 2010-5-22 19:03:00

<div><strong><font face="Times New Roman" color="#000000" size="3">void createNewLayer(AcDbDatabase *pDb)</font></strong></div><div><strong><font face="Times New Roman" color="#000000" size="3">createNewLayer();有错误。</font></strong></div>

xhsd 发表于 2010-5-22 23:15:00

请问错在哪里?能否指点一下

梦幻神话 发表于 2010-5-24 09:06:00

<p><strong><font face="Times New Roman" color="#000000" size="3">void createNewLayer(AcDbDatabase *pDb) <br/>{ </font></strong></p><div><strong><font face="Times New Roman" size="3"><font color="#000000">AcDbLayerTable *pLayerTable;&nbsp;<br/>pDb -&gt;getSymbolTable(pLayerTable, AcDb::kForWrite); <br/>&nbsp;<br/>AcDbLayerTableRecord *pLayerTableRecord = new AcDbLayerTableRecord; <br/>pLayerTableRecord-&gt;setName("ASDK_MYLAYER"); <br/>// 如果没有指定层的其他属性,就使用缺省值 <br/>pLayerTable-&gt;add(pLayerTableRecord); <br/>pLayerTable-&gt;close(); <br/>pLayerTableRecord-&gt;close(); <br/>} <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>void createDwg2()<br/>{<br/>AcDbDatabase *pDb = new AcDbDatabase();</font><div></div><p><font face="Tahoma">&nbsp; </font></p></font></strong></div><div></div><p><font face="Tahoma">&nbsp; </font></p><div><strong><font face="Times New Roman" color="#000000" size="3">createNewLayer(pDb);</font></strong></div><div><strong><font face="Times New Roman" size="3"></font></strong>&nbsp;</div><div><strong><font face="Times New Roman" color="#000000" size="3">pDb-&gt;saveAs("c:\\test2.dwg");<br/>delete pDb;</font></strong></div><div><strong><font face="Times New Roman" color="#000000" size="3">pDb = NULL;<br/>}</font></strong></div>

xhsd 发表于 2010-5-24 23:55:00

解决,非常感谢
页: [1]
查看完整版本: [求助]新建图形数据库中创建图层问题--困扰我好久了,跪求高手指点