uusky 发表于 2005-9-1 09:33:00

[ARX]cad报错 (附源码)

<P>dd&nbsp; </P>
<P>这是个曲柄摇杆机构的运动轨迹的仿真程序,代码编译无错,但在CAD2002中出错提示如下:</P>
<P>http://bbs.njut.edu.cn/servlet/JiveServlet/download/106-61747-73576377-40524/11.jpg</P>
<P>希望高人们能指点一下,先在这里谢过了!</P>

uusky 发表于 2005-9-1 09:39:00

<P>主要代码如下:<BR>#include "StdAfx.h"<BR>#include "StdArx.h"<BR>#include "resource.h"<BR>#include &lt;stdio.h&gt;<BR>#include "adslib.h"<BR>#include "adesk.h"<BR>#include "aced.h"<BR>#include "math.h"<BR>#include "acdb.h"<BR>#include "dbents.h"<BR>#include &lt;dbsymtb.h&gt;<BR>#include "rxregsvc.h"<BR>#include &lt;rxdlinkr.h&gt;<BR>#include &lt;geassign.h&gt;<BR>#include &lt;dbapserv.h&gt;</P>
<P>//-----------------------------------------------------------------------------<BR>// This is command 'MOTOIN, by&nbsp; , , <BR>void xlgisMotoin()<BR>{<BR>#ifdef OARXWIZDEBUG<BR>&nbsp;acutPrintf ("\nOARXWIZDEBUG - xlgisMotoin() called.");<BR>#endif // OARXWIZDEBUG<BR>&nbsp;<BR>&nbsp;double A={130.000,83.000,0.000};<BR>&nbsp;double D={213.000,83.000,0.000};<BR>&nbsp;//四边边长<BR>&nbsp;double a,b,c,d;<BR>&nbsp;a=34.000;<BR>&nbsp;b=101.000;<BR>&nbsp;c=64.000;<BR>&nbsp;d=D-A;<BR>&nbsp;//定义四点abcd<BR>&nbsp;AcGePoint3d&nbsp; APt(A,A,A);<BR>&nbsp;AcGePoint3d&nbsp; DPt(D,D,D);<BR>&nbsp;double B;<BR>&nbsp;double C;<BR>&nbsp;//B点和C点的运动轨迹计算结果数组<BR>&nbsp;AcGePoint3d&nbsp; BPt;<BR>&nbsp;AcGePoint3d&nbsp; CPt;<BR>&nbsp;//////////////////////////<BR>&nbsp;///计算分析<BR>&nbsp;double DETFI,FI,THETA,THETA1,THETA2;<BR>&nbsp;DETFI=3.1415926*10/180;//步长<BR>&nbsp;FI=0;//初始角度<BR>&nbsp;for (int i=0;i&lt;36;i++)&nbsp; <BR>&nbsp;{//计算各点的坐标<BR>&nbsp;&nbsp;double BD=sqrt(a*a+d*d-2*a*d*cos(FI));<BR>&nbsp;&nbsp;THETA1=acos(-(a*a-d*d-BD*BD)/(2*d*BD));<BR>&nbsp;&nbsp;THETA2=acos(-(b*b-c*c-BD*BD)/(2*c*BD));<BR>&nbsp;&nbsp;THETA=THETA1+THETA2;<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;//B点坐标<BR>&nbsp;&nbsp;B=A+a*cos(FI);<BR>&nbsp;&nbsp;B=A+a*sin(FI);<BR>&nbsp;&nbsp;B=0.000;<BR>&nbsp;&nbsp;//C点坐标<BR>&nbsp;&nbsp;C=D+c*cos(THETA);<BR>&nbsp;&nbsp;C=D+c*sin(THETA);<BR>&nbsp;&nbsp;C=0.000;<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;FI=FI+DETFI;<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;BPt.x=B;<BR>&nbsp;&nbsp;BPt.y=B;<BR>&nbsp;&nbsp;BPt.z=B;<BR>&nbsp;&nbsp;CPt.x=C;<BR>&nbsp;&nbsp;CPt.y=C;<BR>&nbsp;&nbsp;CPt.y=C;<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;//创建各图形<BR>&nbsp;AcDbLine&nbsp; *pLine=new&nbsp; AcDbLine(APt,DPt);//创建直线AD实体对象<BR>&nbsp;<BR>&nbsp;AcDbBlockTable *pBlockTable;<BR>&nbsp;acdbHostApplicationServices()-&gt;workingDatabase()-&gt;getBlockTable(<BR>&nbsp;&nbsp;pBlockTable,AcDb::kForRead);//&nbsp;&nbsp;&nbsp; //获得当前块表(下)<BR>&nbsp;//获得当前块表的块表记录(下)<BR>&nbsp;&nbsp;&nbsp; AcDbBlockTableRecord *pBlockTableRecord;<BR>&nbsp;&nbsp;&nbsp; pBlockTable-&gt;getAt(ACDB_MODEL_SPACE, pBlockTableRecord,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AcDb::kForWrite);<BR>&nbsp;&nbsp;&nbsp; pBlockTable-&gt;close();//使用完毕,关闭块表<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;AcDbObjectId&nbsp; lineId;<BR>&nbsp;AcDbObjectId&nbsp; circleId_A;<BR>&nbsp;AcDbObjectId&nbsp; circleId_D;<BR>&nbsp;AcDbCircle&nbsp; *pCircleA;<BR>&nbsp;AcDbCircle&nbsp; *pCircleD;<BR>&nbsp;pCircleA=new&nbsp; AcDbCircle(APt,AcGeVector3d(0,0,1),1);<BR>&nbsp;//创建A点小圆实体对象R=1<BR>&nbsp;pCircleD=new&nbsp; AcDbCircle(DPt,AcGeVector3d(0,0,1),1);<BR>&nbsp;//创建D点小圆实体对象R=1<BR>&nbsp;<BR>&nbsp;pBlockTableRecord-&gt;appendAcDbEntity(lineId,pLine);<BR>&nbsp;//将直线IO加入到块表记录中<BR>&nbsp;pBlockTableRecord-&gt;appendAcDbEntity(circleId_A,pCircleA);<BR>&nbsp;//将A点小圆加入到块表记录中<BR>&nbsp;pBlockTableRecord-&gt;appendAcDbEntity(circleId_D,pCircleD);<BR>&nbsp;//将D点小圆加入到块表记录中<BR>&nbsp;pBlockTableRecord-&gt;close();//关闭块表记录<BR>&nbsp;&nbsp;&nbsp; pLine-&gt;close();//关闭实体直线AD对象<BR>&nbsp;pCircleA-&gt;close();//关闭A点小圆实体对象<BR>&nbsp;pCircleD-&gt;close();//关闭D点小圆实体对象<BR>&nbsp;<BR>&nbsp;//----------------------------------------------------------------<BR>&nbsp;AcDbObjectId&nbsp; circleId_B;<BR>&nbsp;AcDbObjectId&nbsp; circleId_C;<BR>&nbsp;AcDbCircle&nbsp; *pCircleB;<BR>&nbsp;AcDbCircle&nbsp; *pCircleC;<BR>&nbsp;for ( i=0;i&lt;36;i++ ) <BR>&nbsp;{//创建BC点小圆 和AB&nbsp; BC&nbsp; CD<BR>&nbsp;&nbsp;AcDbObjectId&nbsp; idLine_AB;<BR>&nbsp;&nbsp;AcDbObjectId&nbsp; idLine_BC;<BR>&nbsp;&nbsp;AcDbObjectId&nbsp; idLine_CD;<BR>&nbsp;&nbsp;//获得当前块表(下)<BR>&nbsp;&nbsp;AcDbBlockTable *pBlockTable;<BR>&nbsp;&nbsp;acdbHostApplicationServices()-&gt;workingDatabase()<BR>&nbsp;&nbsp;&nbsp;-&gt;getSymbolTable(pBlockTable, AcDb::kForRead);<BR>&nbsp;&nbsp;//获得当前块表的块表记录(下)<BR>&nbsp;&nbsp;AcDbBlockTableRecord *pBlockTableRecord;<BR>&nbsp;&nbsp;pBlockTable-&gt;getAt(ACDB_MODEL_SPACE, pBlockTableRecord,<BR>&nbsp;&nbsp;&nbsp;AcDb::kForWrite);<BR>&nbsp;&nbsp;pBlockTable-&gt;close();//使用完毕,关闭块表<BR>&nbsp;&nbsp;pCircleB=new&nbsp; AcDbCircle(BPt,AcGeVector3d(0,0,1),1);<BR>&nbsp;&nbsp;//创建B点小圆实体对象R=1<BR>&nbsp;&nbsp;pCircleC=new&nbsp; AcDbCircle(CPt,AcGeVector3d(0,0,1),1);<BR>&nbsp;&nbsp;//创建C点小圆实体对象R=1<BR>&nbsp;&nbsp;AcDbLine *pLine_AB=new&nbsp; AcDbLine(APt,BPt);<BR>&nbsp;&nbsp;//创建AB实体对象<BR>&nbsp;&nbsp;AcDbLine *pLine_BC=new&nbsp; AcDbLine(BPt,CPt);<BR>&nbsp;&nbsp;//创建BC实体对象<BR>&nbsp;&nbsp;AcDbLine *pLine_CD=new&nbsp; AcDbLine(CPt,DPt);&nbsp;&nbsp; //创建CD实体对象<BR>&nbsp;&nbsp;//加入到块表记录<BR>&nbsp;&nbsp;pBlockTableRecord-&gt;appendAcDbEntity(circleId_B,pCircleB);<BR>&nbsp;&nbsp;pBlockTableRecord-&gt;appendAcDbEntity(circleId_C,pCircleC);<BR>&nbsp;&nbsp;pBlockTableRecord-&gt;appendAcDbEntity(idLine_AB,pLine_AB);<BR>&nbsp;&nbsp;pBlockTableRecord-&gt;appendAcDbEntity(idLine_BC,pLine_BC);<BR>&nbsp;&nbsp;pBlockTableRecord-&gt;appendAcDbEntity(idLine_CD,pLine_CD);<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;pBlockTableRecord-&gt;close();//关闭块表记录<BR>&nbsp;&nbsp;//关闭各图形对象<BR>&nbsp;&nbsp;pCircleB-&gt;close();<BR>&nbsp;&nbsp;pCircleC-&gt;close();<BR>&nbsp;&nbsp;pLine_AB-&gt;close();<BR>&nbsp;&nbsp;pLine_BC-&gt;close();<BR>&nbsp;&nbsp;pLine_CD-&gt;close();<BR>&nbsp;}//循环结束<BR>&nbsp;// TODO: Implement the command<BR>&nbsp;<BR>}<BR></P>

MingSoft 发表于 2005-9-1 13:14:00

出现C000005的错误原因就是指针是null的时候进行了操作, 你检查看看

huihuo 发表于 2005-9-2 10:14:00

<P>我下载了,运行没有问题。</P>

uusky 发表于 2005-9-6 13:54:00

<P>我还是没查出来!那位高手能帮忙看下吗?先谢了</P>

fazi 发表于 2005-9-7 11:47:00

<P>没有什么问题一切正常 你重新加载一下尝试一下</P>

uusky 发表于 2005-9-7 17:34:00

<P>呵呵&nbsp; 奇怪&nbsp; 是没问题!是不是因为我这回是在release模式下编译的缘故啊</P>
页: [1]
查看完整版本: [ARX]cad报错 (附源码)