[求助]新建图形数据库中创建图层问题--困扰我好久了,跪求高手指点
<strong>我新建一个图层,然后添加到后台一个新建的图形数据库中(此处必须是后台新建的数据库),并保存为test2.dwg,但是打开test2.dwg文件后,新建的图层一直没有创建成功。</strong><div> </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 * pCurDb = pDb;</font></strong></div><strong><font face="Times New Roman" size="3"><div><br/><font color="#000000">AcDbLayerTable *pLayerTable; <br/>pCurDb = acdbHostApplicationServices()->workingDatabase() ->getSymbolTable(pLayerTable, AcDb::kForWrite); <br/> <br/>AcDbLayerTableRecord *pLayerTableRecord = new AcDbLayerTableRecord; <br/>pLayerTableRecord->setName("ASDK_MYLAYER"); <br/>// 如果没有指定层的其他属性,就使用缺省值 <br/>pLayerTable->add(pLayerTableRecord); <br/>pLayerTable->close(); <br/>pLayerTableRecord->close(); <br/>} <br/> <br/>void createDwg2(pDb)<br/>{<br/>AcDbDatabase *pDb = new AcDbDatabase();</font></div><div></div></font></strong> <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> </div><div><strong><font face="Times New Roman" color="#000000" size="3">pDb->saveAs("c:\\test2.dwg");<br/>delete pDb;<br/>}</font></strong></div><div><strong><font face="Times New Roman" color="#000000" size="3"></font></strong> </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 = <u> acdbHostApplicationServices()->workingDatabase() </u>->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> <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> 请问错在哪里?能否指点一下 <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; <br/>pDb ->getSymbolTable(pLayerTable, AcDb::kForWrite); <br/> <br/>AcDbLayerTableRecord *pLayerTableRecord = new AcDbLayerTableRecord; <br/>pLayerTableRecord->setName("ASDK_MYLAYER"); <br/>// 如果没有指定层的其他属性,就使用缺省值 <br/>pLayerTable->add(pLayerTableRecord); <br/>pLayerTable->close(); <br/>pLayerTableRecord->close(); <br/>} <br/> <br/>void createDwg2()<br/>{<br/>AcDbDatabase *pDb = new AcDbDatabase();</font><div></div><p><font face="Tahoma"> </font></p></font></strong></div><div></div><p><font face="Tahoma"> </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> </div><div><strong><font face="Times New Roman" color="#000000" size="3">pDb->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> 解决,非常感谢
页:
[1]