[ARX]cad报错 (附源码)
<P>dd </P><P>这是个曲柄摇杆机构的运动轨迹的仿真程序,代码编译无错,但在CAD2002中出错提示如下:</P>
<P>http://bbs.njut.edu.cn/servlet/JiveServlet/download/106-61747-73576377-40524/11.jpg</P>
<P>希望高人们能指点一下,先在这里谢过了!</P> <P>主要代码如下:<BR>#include "StdAfx.h"<BR>#include "StdArx.h"<BR>#include "resource.h"<BR>#include <stdio.h><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 <dbsymtb.h><BR>#include "rxregsvc.h"<BR>#include <rxdlinkr.h><BR>#include <geassign.h><BR>#include <dbapserv.h></P>
<P>//-----------------------------------------------------------------------------<BR>// This is command 'MOTOIN, by , , <BR>void xlgisMotoin()<BR>{<BR>#ifdef OARXWIZDEBUG<BR> acutPrintf ("\nOARXWIZDEBUG - xlgisMotoin() called.");<BR>#endif // OARXWIZDEBUG<BR> <BR> double A={130.000,83.000,0.000};<BR> double D={213.000,83.000,0.000};<BR> //四边边长<BR> double a,b,c,d;<BR> a=34.000;<BR> b=101.000;<BR> c=64.000;<BR> d=D-A;<BR> //定义四点abcd<BR> AcGePoint3d APt(A,A,A);<BR> AcGePoint3d DPt(D,D,D);<BR> double B;<BR> double C;<BR> //B点和C点的运动轨迹计算结果数组<BR> AcGePoint3d BPt;<BR> AcGePoint3d CPt;<BR> //////////////////////////<BR> ///计算分析<BR> double DETFI,FI,THETA,THETA1,THETA2;<BR> DETFI=3.1415926*10/180;//步长<BR> FI=0;//初始角度<BR> for (int i=0;i<36;i++) <BR> {//计算各点的坐标<BR> double BD=sqrt(a*a+d*d-2*a*d*cos(FI));<BR> THETA1=acos(-(a*a-d*d-BD*BD)/(2*d*BD));<BR> THETA2=acos(-(b*b-c*c-BD*BD)/(2*c*BD));<BR> THETA=THETA1+THETA2;<BR> <BR> //B点坐标<BR> B=A+a*cos(FI);<BR> B=A+a*sin(FI);<BR> B=0.000;<BR> //C点坐标<BR> C=D+c*cos(THETA);<BR> C=D+c*sin(THETA);<BR> C=0.000;<BR> <BR> <BR> FI=FI+DETFI;<BR> <BR> BPt.x=B;<BR> BPt.y=B;<BR> BPt.z=B;<BR> CPt.x=C;<BR> CPt.y=C;<BR> CPt.y=C;<BR> }<BR> <BR> <BR> <BR> //创建各图形<BR> AcDbLine *pLine=new AcDbLine(APt,DPt);//创建直线AD实体对象<BR> <BR> AcDbBlockTable *pBlockTable;<BR> acdbHostApplicationServices()->workingDatabase()->getBlockTable(<BR> pBlockTable,AcDb::kForRead);// //获得当前块表(下)<BR> //获得当前块表的块表记录(下)<BR> AcDbBlockTableRecord *pBlockTableRecord;<BR> pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,<BR> AcDb::kForWrite);<BR> pBlockTable->close();//使用完毕,关闭块表<BR> <BR> <BR> AcDbObjectId lineId;<BR> AcDbObjectId circleId_A;<BR> AcDbObjectId circleId_D;<BR> AcDbCircle *pCircleA;<BR> AcDbCircle *pCircleD;<BR> pCircleA=new AcDbCircle(APt,AcGeVector3d(0,0,1),1);<BR> //创建A点小圆实体对象R=1<BR> pCircleD=new AcDbCircle(DPt,AcGeVector3d(0,0,1),1);<BR> //创建D点小圆实体对象R=1<BR> <BR> pBlockTableRecord->appendAcDbEntity(lineId,pLine);<BR> //将直线IO加入到块表记录中<BR> pBlockTableRecord->appendAcDbEntity(circleId_A,pCircleA);<BR> //将A点小圆加入到块表记录中<BR> pBlockTableRecord->appendAcDbEntity(circleId_D,pCircleD);<BR> //将D点小圆加入到块表记录中<BR> pBlockTableRecord->close();//关闭块表记录<BR> pLine->close();//关闭实体直线AD对象<BR> pCircleA->close();//关闭A点小圆实体对象<BR> pCircleD->close();//关闭D点小圆实体对象<BR> <BR> //----------------------------------------------------------------<BR> AcDbObjectId circleId_B;<BR> AcDbObjectId circleId_C;<BR> AcDbCircle *pCircleB;<BR> AcDbCircle *pCircleC;<BR> for ( i=0;i<36;i++ ) <BR> {//创建BC点小圆 和AB BC CD<BR> AcDbObjectId idLine_AB;<BR> AcDbObjectId idLine_BC;<BR> AcDbObjectId idLine_CD;<BR> //获得当前块表(下)<BR> AcDbBlockTable *pBlockTable;<BR> acdbHostApplicationServices()->workingDatabase()<BR> ->getSymbolTable(pBlockTable, AcDb::kForRead);<BR> //获得当前块表的块表记录(下)<BR> AcDbBlockTableRecord *pBlockTableRecord;<BR> pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,<BR> AcDb::kForWrite);<BR> pBlockTable->close();//使用完毕,关闭块表<BR> pCircleB=new AcDbCircle(BPt,AcGeVector3d(0,0,1),1);<BR> //创建B点小圆实体对象R=1<BR> pCircleC=new AcDbCircle(CPt,AcGeVector3d(0,0,1),1);<BR> //创建C点小圆实体对象R=1<BR> AcDbLine *pLine_AB=new AcDbLine(APt,BPt);<BR> //创建AB实体对象<BR> AcDbLine *pLine_BC=new AcDbLine(BPt,CPt);<BR> //创建BC实体对象<BR> AcDbLine *pLine_CD=new AcDbLine(CPt,DPt); //创建CD实体对象<BR> //加入到块表记录<BR> pBlockTableRecord->appendAcDbEntity(circleId_B,pCircleB);<BR> pBlockTableRecord->appendAcDbEntity(circleId_C,pCircleC);<BR> pBlockTableRecord->appendAcDbEntity(idLine_AB,pLine_AB);<BR> pBlockTableRecord->appendAcDbEntity(idLine_BC,pLine_BC);<BR> pBlockTableRecord->appendAcDbEntity(idLine_CD,pLine_CD);<BR> <BR> pBlockTableRecord->close();//关闭块表记录<BR> //关闭各图形对象<BR> pCircleB->close();<BR> pCircleC->close();<BR> pLine_AB->close();<BR> pLine_BC->close();<BR> pLine_CD->close();<BR> }//循环结束<BR> // TODO: Implement the command<BR> <BR>}<BR></P> 出现C000005的错误原因就是指针是null的时候进行了操作, 你检查看看 <P>我下载了,运行没有问题。</P> <P>我还是没查出来!那位高手能帮忙看下吗?先谢了</P> <P>没有什么问题一切正常 你重新加载一下尝试一下</P> <P>呵呵 奇怪 是没问题!是不是因为我这回是在release模式下编译的缘故啊</P>
页:
[1]