cad新学生 发表于 2009-11-21 10:30:00

[求助]新建文档画图问题,各位指点一下程序错在哪?

<p>AcDbDatabase* CCreateEnity::NewDocDatabase() <br/>{&nbsp;<br/><br/>&nbsp;AcDbDatabase* pNewDb=NULL; <br/>&nbsp;static ACHAR pData[] =L"acad.dwt"; <br/>&nbsp; <br/>&nbsp;<font color="#e61a1a">acDocManager-&gt;executeInApplicationContext(CreateDoc,(void *)pData);&nbsp;</font></p><p>&nbsp; <font style="BACKGROUND-COLOR: #dddd22;">为什么执行这句后下面语句不执行,只有回到cad切换回原来的文档才响应而且运行到实体关闭(绿色字体)报错,貌似数据库没有切换,该怎么改呢?有什么书或资料,高手们指点一下,谢谢!</font><br/>&nbsp;AcApDocument* npDoc=GetLastDoc();<br/>&nbsp;acDocManager-&gt;activateDocument(npDoc);<br/>&nbsp;pNewDb=npDoc-&gt;database(); <br/>&nbsp;if(!pNewDb) return NULL; <br/>&nbsp;&nbsp;&nbsp; acDocManager-&gt;setCurDocument(npDoc);<br/>&nbsp;&nbsp; /* acdbHostApplicationServices()-&gt;setWorkingDatabase(pNewDb);*/<br/>&nbsp;/*pNewDb=acdbHostApplicationServices()-&gt;workingDatabase(); */</p><p>&nbsp;AcDbBlockTable *pBtbl; <br/>&nbsp;pNewDb-&gt;getSymbolTable(pBtbl, AcDb::kForRead); </p><p>&nbsp;AcDbBlockTableRecord *pBtblRcd; <br/>&nbsp;pBtbl-&gt;getAt(ACDB_MODEL_SPACE, pBtblRcd, <br/>&nbsp;&nbsp;AcDb::kForWrite); <br/>&nbsp;pBtbl-&gt;close(); </p><p>&nbsp;AcDbCircle *pCir1 = new AcDbCircle(AcGePoint3d(1,1,1), <br/>&nbsp;&nbsp;AcGeVector3d(0,0,1), <br/>&nbsp;&nbsp;1.0), <br/>&nbsp;&nbsp;*pCir2 = new AcDbCircle(AcGePoint3d(4,4,4), <br/>&nbsp;&nbsp;AcGeVector3d(0,0,1), <br/>&nbsp;&nbsp;2.0); <br/><font color="#68f709">&nbsp;pBtblRcd-&gt;appendAcDbEntity(pCir1); <br/>&nbsp;pCir1-&gt;close();</font>
        </p><p>&nbsp;pBtblRcd-&gt;appendAcDbEntity(pCir2); <br/>&nbsp;pCir2-&gt;close(); <br/>&nbsp;pBtblRcd-&gt;close(); </p><p>&nbsp;delete pNewDb;<br/>&nbsp;return pNewDb; <br/>} </p><p>void CreateDoc( void *pData) <br/>{ <br/>&nbsp;AcApDocument* pDoc = acDocManager-&gt;curDocument(); <br/>&nbsp;if (acDocManager-&gt;isApplicationContext())<br/>&nbsp;{ <br/>&nbsp;&nbsp;acDocManager-&gt;appContextNewDocument((const ACHAR *)pData); <br/>&nbsp;} <br/>} </p>

luowy 发表于 2009-11-24 14:02:00

本帖最后由 作者 于 2009-11-24 18:22:46 编辑 <br /><br /> <p><font color="#e61a1a">1、你需要在creatDoc那里切换回你原来的文档,MDI文档机制让新建的文档变成了当前活动文档,arx代码在原文档的执行被中断了,这个不难理解,你在一个文档中画线,当切换文档后再回来,会发现画线的命令依然在等待相应。</font></p><p><font color="#e61a1a">2、至于你说的关闭圆那里报错,是因为你新建的文档处于锁定状态,你需要在setDocument那里打开。</font></p><p><font color="#e61a1a">3、以上完成了,还是会出错,这回到之前有人说的那个内存0x000005的问题了,这个我又去研究一下,发现如果将增加实体的代码去掉,函数是正常运行的。迷糊中,解决尚不能。</font></p><p><font color="#e61a1a"></font></p><p><font color="#e61a1a">=====</font></p><p><font color="#e61a1a">问题已经解决,源码稍后公布!</font></p>

cad新学生 发表于 2009-11-27 17:52:00

<p>谢谢!等待。。。</p><p></p>
页: [1]
查看完整版本: [求助]新建文档画图问题,各位指点一下程序错在哪?