发生致命错误,请大伙帮忙看下!
<FONT face=宋体 size=2>我自定义了一个矩形类,就是可以拖放的那种.但是不知道为什么当我拖放完成时候会出现致命错误.无法完成矩形的最终绘制.<BR>哪位大哥可以帮小弟看看是什么原因.<BR><BR>拖放结束后出现: Unhandled Expception C0000005(Access Violation Reading Ox0054)at address 65462AC9h<BR>关掉AUTCAD后 出现 :INTERNAL ERROR!XCOMMAND.cpp@3337:Was Open For Write<BR>代码如下:<BR><BR>class CMARectWindow : public AcDbEntity<BR>{<BR>public:<BR><BR>ACRX_DECLARE_MEMBERS(CMARectWindow);<BR>CMARectWindow();<BR>virtual ~CMARectWindow();<BR>virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler* pFiler) const;<BR>virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler* pFiler);<BR>virtual Acad::ErrorStatus dxfInFields(AcDbDxfFiler* pFiler);<BR>virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler* pFiler)const;<BR>virtual Acad::ErrorStatus getGripPoints(AcGePoint3dArray& gripPoints, AcDbIntArray& osnapMasks, AcDbIntArray& geomIds) const;<BR>virtual Acad::ErrorStatus moveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset);<BR>virtual Adesk::Boolean worldDraw(AcGiWorldDraw* mode);<BR>AcGePoint3d m_UpLeftPt;<BR>AcGePoint3d m_DownRightPt;<BR>AcGePoint3d m_DownLeftPt;<BR>AcGePoint3d m_UpRightPt; <BR>private:<BR>};<BR><BR><BR><BR><BR>ACRX_DXF_DEFINE_MEMBERS(CMARectWindow, AcDbEntity,<BR>AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,<BR>0,<BR>CUSTOMENTITY, /*MSG0*/AUTOCAD);<BR><BR><BR>CMARectWindow::CMARectWindow()<BR>{<BR><BR>}<BR><BR>CMARectWindow::~CMARectWindow()<BR>{}<BR><BR>Acad::ErrorStatus CMARectWindow::getGripPoints(AcGePoint3dArray& gripPoints, AcDbIntArray& osnapMasks, AcDbIntArray& geomIds)const<BR>{<BR>assertReadEnabled();<BR>AcGePoint3d um,lm,rm,bm;<BR>um=m_UpLeftPt+0.5*(m_UpRightPt-m_UpLeftPt);<BR>lm=m_DownLeftPt+0.5*(m_UpLeftPt-m_DownLeftPt);<BR>rm=m_DownRightPt+0.5*(m_UpRightPt-m_DownRightPt);<BR>bm=m_DownLeftPt+0.5*(m_DownRightPt-m_DownLeftPt);<BR>gripPoints.append(um);<BR>gripPoints.append(rm);<BR>gripPoints.append(bm);<BR>gripPoints.append(lm);<BR>return Acad::eOk;<BR>}<BR>Acad::ErrorStatus CMARectWindow::moveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset)<BR>{<BR>assertWriteEnabled();<BR>switch(indices) {<BR>case 0:<BR>m_UpLeftPt+=offset.y;<BR>m_UpRightPt+=offset.y;<BR>break;<BR>case 1:<BR>m_UpRightPt+=offset.x;<BR>m_DownRightPt+=offset.y;<BR>break;<BR>case 2:<BR>m_DownLeftPt-=offset.y;<BR>m_DownRightPt-=offset.y;<BR>break;<BR>case 3:<BR>m_DownLeftPt-=offset.x;<BR>m_UpLeftPt-=offset.x;<BR>break;<BR>default:<BR>break;<BR>}<BR>return Acad::eOk;<BR>}<BR>Adesk::Boolean CMARectWindow::worldDraw(AcGiWorldDraw* mode)<BR>{<BR>assertReadEnabled();<BR><BR>m_DownLeftPt=m_UpLeftPt;<BR>m_DownLeftPt=m_DownRightPt;<BR>m_DownLeftPt=0;<BR>m_UpRightPt=m_DownRightPt;<BR>m_UpRightPt=m_UpLeftPt;<BR>m_UpRightPt=0;<BR>AcGePoint3d pLineArray; <BR>pLineArray =m_UpLeftPt;<BR>pLineArray =m_UpRightPt;<BR>pLineArray =m_DownRightPt;<BR>pLineArray =m_DownLeftPt;<BR>pLineArray =m_UpLeftPt;<BR>mode->geometry().polyline(5, pLineArray);<BR><BR>return Adesk::kTrue; <BR>}<BR><BR>Acad::ErrorStatus CMARectWindow::dwgInFields(AcDbDwgFiler* pFiler)<BR>{<BR>assertWriteEnabled();<BR><BR>Acad::ErrorStatus es; <BR>if ((es = AcDbEntity::dwgInFields(pFiler)) != Acad::eOk)<BR>{<BR>return es;<BR>}<BR><BR>pFiler->readItem(&m_UpLeftPt);<BR>pFiler->readItem(&m_DownRightPt);<BR>pFiler->readItem(&m_DownLeftPt);<BR>pFiler->readItem(&m_UpRightPt);<BR>return pFiler->filerStatus();<BR>}<BR><BR>Acad::ErrorStatus CMARectWindow::dwgOutFields(AcDbDwgFiler* pFiler) const<BR>{<BR>assertReadEnabled();<BR><BR>Acad::ErrorStatus es;<BR>if ((es = AcDbEntity::dwgOutFields(pFiler)) != Acad::eOk) <BR>{<BR>return es;<BR>}<BR><BR>pFiler->writeItem(m_UpLeftPt);<BR>pFiler->writeItem(m_DownRightPt);<BR>pFiler->writeItem(m_UpRightPt);<BR>pFiler->writeItem(m_DownLeftPt);<BR>return pFiler->filerStatus();<BR>}<BR><BR>Acad::ErrorStatus CMARectWindow::dxfInFields(AcDbDxfFiler* pFiler)<BR>{<BR>assertWriteEnabled();<BR>Acad::ErrorStatus es=Acad::eOk;<BR>resbuf rb;<BR>if ((AcDbEntity::dxfInFields(pFiler)!=Acad::eOk)||!pFiler->atSubclassData("CMARectWindow"))<BR>{<BR>return pFiler->filerStatus();<BR>}<BR>AcGePoint3d ulPt,urPt,dlPt,drPt;<BR>while ((es==Acad::eOk)&&(es=pFiler->readResBuf(&rb))==Acad::eOk)<BR>{<BR>switch(rb.restype) {<BR>case kDxfXCoord:<BR>ulPt=asPnt3d(rb.resval.rpoint);<BR>break;<BR>case kDxfXCoord+1:<BR>urPt=asPnt3d(rb.resval.rpoint);<BR>break;<BR>case kDxfXCoord+2:<BR>dlPt=asPnt3d(rb.resval.rpoint);<BR>break;<BR>case kDxfXCoord+3:<BR>drPt=asPnt3d(rb.resval.rpoint);<BR>break;<BR>default:<BR>pFiler->pushBackItem();<BR>es=Acad::eEndOfFile;<BR>break;<BR>}<BR>}<BR>if (es!=Acad::eEndOfFile)<BR>{<BR>return Acad::eInvalidResBuf;<BR>}<BR>return es;<BR><BR>}<BR><BR>Acad::ErrorStatus CMARectWindow::dxfOutFields(AcDbDxfFiler* pFiler) const<BR>{<BR>assertReadEnabled();<BR>Acad::ErrorStatus es;<BR>if ((es=AcDbEntity::dxfOutFields(pFiler))!=Acad::eOk)<BR>{<BR>return es;<BR>}<BR>pFiler->writeItem(AcDb::kDxfSubclass,"CMARectWindow");<BR>pFiler->writeItem(AcDb::kDxfXCoord,m_UpLeftPt);<BR>pFiler->writeItem(AcDb::kDxfXCoord+1,m_UpRightPt);<BR>pFiler->writeItem(AcDb::kDxfXCoord+2,m_DownRightPt);<BR>pFiler->writeItem(AcDb::kDxfXCoord+3,m_DownLeftPt);<BR>return es;<BR>}<BR>class AsdkRectJig:public AcEdJig<BR>{<BR>public:<BR>AsdkRectJig(AcGePoint3d &);<BR>void doIt();<BR>virtual DragStatus sampler();<BR>virtual Adesk::Boolean update();<BR>virtual AcDbEntity* entity() const;<BR>protected:<BR>private:<BR>CMARectWindow *mpRect;<BR>AcGePoint3d mUpLeftPt,mDownRightPt;<BR>double m_length,m_height;<BR>AcGeVector3d mNormal;<BR>};<BR><BR>AsdkRectJig::AsdkRectJig(AcGePoint3d &Pt)<BR>{<BR>mpRect=new CMARectWindow();<BR>mpRect->m_UpLeftPt=Pt;<BR>}<BR><BR>void AsdkRectJig::doIt()<BR>{<BR><BR>setDispPrompt("\nRect choose the second point:");<BR>AcEdJig::DragStatus stat=drag();<BR>append();<BR><BR>}<BR><BR>AcEdJig::DragStatus<BR>AsdkRectJig::sampler()<BR>{<BR>DragStatus stat;<BR>setUserInputControls((UserInputControls)<BR>(AcEdJig::kGovernedByOrthoMode<BR>|AcEdJig::kAccept3dCoordinates<BR>|AcEdJig::kNoNegativeResponseAccepted<BR>|AcEdJig::kNoZeroResponseAccepted));<BR>static AcGePoint3d axispointTemp;<BR>stat=acquirePoint(mDownRightPt);<BR>if (axispointTemp!=mDownRightPt)<BR>{<BR>axispointTemp=mDownRightPt;<BR>}<BR>else if(stat==AcEdJig::kNormal)<BR>{<BR>return AcEdJig::kNoChange;<BR>}<BR>return stat;<BR>}<BR><BR>Adesk::Boolean <BR>AsdkRectJig::update()<BR>{<BR>mpRect->m_DownRightPt=mDownRightPt;<BR>return Adesk::kTrue;<BR>}<BR><BR>AcDbEntity *<BR>AsdkRectJig::entity() const<BR>{<BR>return mpRect;<BR>}<BR><BR>// This is command 'REC'<BR>void studyrectrec()<BR>{<BR>// TODO: Implement the command<BR>AcGePoint3d tempPt;<BR>struct resbuf rbFrom,rbTo;<BR>ads_getpoint(NULL,"\nRect choose the first point:",asDblArray(tempPt));<BR>rbFrom.restype=RTSHORT;<BR>rbFrom.resval.rint=1;<BR>rbTo.restype=RTSHORT;<BR>rbTo.resval.rint=0;<BR>ads_trans(asDblArray(tempPt),&rbFrom,&rbTo,Adesk::kFalse,asDblArray(tempPt));<BR>AsdkRectJig *pJig=new AsdkRectJig(tempPt);<BR>pJig->doIt();<BR>delete pJig;<BR>}</FONT> <P>我的程序也是这样</P><P>我拖动的是一个BlockReference,当我第一次拖动的时候没有问题</P>
<P>但是当我又创建一个Reference的时候当我拖动的时候就会出现上面所说的UnHandled这样的错误提示</P> <P>呵呵 `兄弟真是太谢谢你了,请问兄弟有没有联系方式?QQ ??</P>
<P>请问可不可以连续拖动,并且给所拖动的实体 加上自定义属性</P>
<P>我现在有个程序出现这样的毛病,当拖动一个块引用的时候,拖动完添加到数据库中,然后为该实体添加属性(因为我看到ARX帮助上写的添加属性只能是为数据库常驻实体添加,当一个实体还没有保存到数据库中会出现eNoDatabase这样的情况)</P>
<P>当第一次创建一个块引用,然后设置属性的时候没有问题,但是我要是把这段拖动添加属性的程序放在一个循环里就会出现问题,也就是说,当循环第一次的时候没有问题,但是当循环第二次的时候,就会出现Unhandled错误(出现在jig->drag()处),当我尝试不放在循环里,一次创建一个实体,没有 问题,当我尝试放在循环中但是不添加属性也没有问题~~</P>
<P>这个毛病困扰 我一个星期了~~,请楼上的兄弟帮忙分析是怎么回事,好么??</P>
<P>我QQ:27176970</P>
页:
[1]