[求助] 一个简单程序的收尾问题
<div>用向导创建一个ARX程序,现在就面临最后的close 但是不知道怎么close 。</div><div>编译能通过,但是在AutoCAD里面运行的话,就会导致CAD发生致使错误而关闭</div><div><br/></div><div>请问 ,如何关闭?</div><div><br/></div><div>附:源程序</div><div><br/></div><div> //设定直线的两个端点</div><div> //并创建一个指向对象的指针</div><div> AcGePoint3d p1Start(50,20,0),p2Start(50,40,0),</div><div> p3Start(50,60,0),p4Start(158,80,0),pxStart(100,0,0);</div><div> AcGePoint3d p1End(150,20,0),p2End(150,40,0),</div><div> p3End(150,60,0),p4End(150,80,0),pxEnd(100,100,0);</div><div><br/></div><div><br/></div><div> AcDbLine *p1l=new AcDbLine(p1Start,p1End);</div><div><br/></div><div> AcDbLine *p2l=new AcDbLine(p2Start,p2End);</div><div><br/></div><div> AcDbLine *p3l=new AcDbLine(p3Start,p3End);</div><div> </div><div> AcDbLine *p4l=new AcDbLine(p4Start,p4End);</div><div><br/></div><div> AcDbLine *pxl=new AcDbLine(pxStart,pxEnd);</div><div><br/></div><div><br/></div><div> ////直线的块表指针</div><div> AcDbBlockTable *p1BT,*p2BT,*p3BT,*p4BT,*pxBT;</div><div><br/></div><div> acdbHostApplicationServices()->workingDatabase()</div><div> ->getBlockTable(p1BT,AcDb::kForRead);</div><div><br/></div><div> acdbHostApplicationServices()->workingDatabase()</div><div> ->getBlockTable(p2BT,AcDb::kForRead);</div><div><br/></div><div> acdbHostApplicationServices()->workingDatabase()</div><div> ->getBlockTable(p3BT,AcDb::kForRead);</div><div><br/></div><div> acdbHostApplicationServices()->workingDatabase()</div><div> ->getBlockTable(p4BT,AcDb::kForRead);</div><div><br/></div><div> acdbHostApplicationServices()->workingDatabase()</div><div> ->getBlockTable(pxBT,AcDb::kForRead);</div><div><br/></div><div><br/></div><div> //直线的块表记录的指针</div><div> AcDbBlockTableRecord *p1BTR,*p2BTR,*p3BTR,*p4BTR,*pxBTR;</div><div><br/></div><div><br/></div><div> p1BT->getAt(ACDB_MODEL_SPACE,p1BTR,AcDb::kForWrite);</div><div><br/></div><div> p2BT->getAt(ACDB_MODEL_SPACE,p2BTR,AcDb::kForWrite);</div><div><br/></div><div> p3BT->getAt(ACDB_MODEL_SPACE,p3BTR,AcDb::kForWrite);</div><div><br/></div><div> p4BT->getAt(ACDB_MODEL_SPACE,p4BTR,AcDb::kForWrite);</div><div><br/></div><div> pxBT->getAt(ACDB_MODEL_SPACE,pxBTR,AcDb::kForWrite);</div><div><br/></div><div> //线 将AcDbLine类的对象添加到块表记录中 </div><div> AcDbObjectId l1Id,l2Id,l3Id,l4Id,lxId;</div><div><br/></div><div><br/></div><div> p1BTR->appendAcDbEntity(l1Id,p1l);</div><div> p2BTR->appendAcDbEntity(l2Id,p2l);</div><div> p3BTR->appendAcDbEntity(l3Id,p3l);</div><div> p4BTR->appendAcDbEntity(l4Id,p4l);</div><div> pxBTR->appendAcDbEntity(lxId,pxl);</div><div> </div><div><br/></div><div> /////收尾工作////////</div><div><br/></div><div> // 关闭第一个图形数据库的各种对象 </div><div> p1BT->close();</div><div> p1l->close;</div><div><br/></div><div> p2BT->close();</div><div> p2l->close();</div><div><br/></div><div> p3BT->close();</div><div> p3l->close();</div><div><br/></div><div> p4BT->close();</div><div> p4l->close();</div><div><br/></div><div> pxBT->close();</div><div> pxl->close();</div><div><br/></div><div><br/></div><div><br/></div> <p>/*冗余过多</p><p>AcDbBlockTableRecord *p1BTR,*p2BTR,*p3BTR,*p4BTR,*pxBTR; </p>
<div>p1BT->getAt(ACDB_MODEL_SPACE,p1BTR,AcDb::kForWrite);</div>
<div>p2BT->getAt(ACDB_MODEL_SPACE,p2BTR,AcDb::kForWrite);</div>
<div>p3BT->getAt(ACDB_MODEL_SPACE,p3BTR,AcDb::kForWrite);</div>
<div>p4BT->getAt(ACDB_MODEL_SPACE,p4BTR,AcDb::kForWrite);</div>
<div>pxBT->getAt(ACDB_MODEL_SPACE,pxBTR,AcDb::kForWrite);</div>
<div>*/</div>
<div> </div>
<div><font color="#800080">模型空间是特殊的块表记录对吧,你创建这么多指针操作一条记录是不是太冗余了?</font></div>
<div><font color="#800080">这些容易导致你后面问题的产生,我们看看下面的代码:</font></div>
<div> </div>
<div>// 关闭第一个图形数据库的各种对象
<div>p1BT->close();<font color="#800080"> //你利用此句已经将模型空间关闭了</font></div>
<div>p1l->close;</div>
<div><br/></div>
<div>p2BT->close(); <font color="#800080">//你利用此句又将模型空间关闭一次,问题就出现了。</font></div>
<div>p2l->close();</div>
<div><br/></div>
<div>p3BT->close();</div>
<div>p3l->close();</div>
<div><br/></div>
<div>p4BT->close();</div>
<div>p4l->close();</div>
<div><br/></div>
<div>pxBT->close();</div>
<div>pxl->close();</div>
<div> </div>
<div>你应该先看看ObjectARX中的例子,然后再编写自己的代码,这样你会对操作CAD有一个新的认识。</div></div> 又增加了一个新的知识点 这个问题困惑了很久,原来是块表的理解不够<div><br/></div><div>感谢!</div>
页:
[1]