uusky 发表于 2005-9-20 09:29:00

[ARX]C++编译无错 CAD非正常退出(附图)

<P>我的程序如下:</P>
<P>ads_point pt;<BR>&nbsp;int NodeNumCount;&nbsp; //定义节点数,即最大的节点编号数值</P>
<P>&nbsp;acedGetInt("请输入多边形顶点数:",&amp;NodeNumCount);<BR>&nbsp;&nbsp;if(acedGetPoint(NULL,"\n请选择起始点:",pt)==RTNORM)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;xpt.Format("%g",pt); <BR>&nbsp;&nbsp;&nbsp;ypt.Format("%g",pt);<BR>&nbsp;&nbsp;&nbsp;acutPrintf("\n起始点坐标为:%s,%s",xpt,ypt);<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;xco=atof(xpt);<BR>&nbsp;&nbsp;yco=atof(ypt);<BR>&nbsp;for(int i=0;i&lt;NodeNumCount;i++)<BR>&nbsp;{<BR>&nbsp;&nbsp;&nbsp;if(acedGetPoint(NULL,"\n拾取下一点:",pt)==RTNORM)<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;xpt.Format("%g",pt); <BR>&nbsp;&nbsp;&nbsp;ypt.Format("%g",pt);<BR>&nbsp;&nbsp;&nbsp;acutPrintf("\n该点坐标为:%s,%s",xpt,ypt);<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;xco=atof(xpt);<BR>&nbsp;&nbsp;yco=atof(ypt);<BR>//pick点,连续画直线<BR>&nbsp;AcDbBlockTableRecord *pBlkTableRcd<BR>&nbsp;&nbsp;=new AcDbBlockTableRecord();//创建块表记录<BR>&nbsp;//以写方式得到当前块表的指针<BR>&nbsp;AcDbBlockTable *pBlkTable=NULL; <BR>&nbsp;acdbHostApplicationServices()-&gt;workingDatabase()<BR>&nbsp;&nbsp;-&gt;getSymbolTable(pBlkTable, AcDb::kForWrite);<BR>&nbsp;//将新的块表记录加入块表中,并获得块表记录的ID<BR>&nbsp;AcDbObjectId Id;<BR>&nbsp;pBlkTable-&gt;add(Id, pBlkTableRcd);<BR>&nbsp;pBlkTable-&gt;close();<BR>&nbsp;&nbsp;//生成直线<BR>&nbsp;&nbsp;AcGePoint3d startPt(xco,yco,0.0);//定义直线起点<BR>&nbsp;&nbsp;AcGePoint3d endPt(xco,yco,0.0);//定义直线终点<BR>&nbsp; &nbsp;AcDbLine *pLine=new AcDbLine(startPt,endPt);<BR>&nbsp;&nbsp;AcDbBlockTable *pBlkTable2=NULL;<BR>&nbsp;&nbsp;acdbHostApplicationServices()-&gt;workingDatabase()<BR>&nbsp;&nbsp;&nbsp;-&gt;getSymbolTable(pBlkTable2, AcDb::kForRead);<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;pBlkTable2-&gt;getAt(ACDB_MODEL_SPACE, pBlkTableRcd,<BR>&nbsp;&nbsp;&nbsp;AcDb::kForWrite);<BR>&nbsp;&nbsp;pBlkTable2-&gt;close();<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;AcDbObjectId lineId;<BR>&nbsp;&nbsp;pBlkTableRcd-&gt;appendAcDbEntity(lineId, pLine);<BR>&nbsp;//&nbsp;pLine-&gt;setLayer("Layer_Frame");//设置创建轮廓线的层为"Layer_Frame"<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;pBlkTableRcd-&gt;close();<BR>&nbsp;&nbsp;pLine-&gt;close();<BR>&nbsp;}</P>
<P>如上是随点画n边形的一段代码,能画n边形,但是退出时会连续弹出两个对话框,</P>
<P>如下:(肯定是上面这段代码的问题,之前也有朋友问过类似的问题,望高手指教)</P>
<P>http://img151.photo.163.com/xueliang4321/16458053/396107286.jpg</P>http://img151.photo.163.com/xueliang4321/16458053/396107404.jpg

anston 发表于 2005-9-20 13:31:00

本帖最后由 作者 于 2005-9-20 22:36:50 编辑 <br /><br /> <P>现在应该搞定了吧^_^</P>
页: [1]
查看完整版本: [ARX]C++编译无错 CAD非正常退出(附图)