明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3643|回复: 4

发生致命错误,请大伙帮忙看下!

[复制链接]
发表于 2006-8-31 15:33:00 | 显示全部楼层 |阅读模式
我自定义了一个矩形类,就是可以拖放的那种.但是不知道为什么当我拖放完成时候会出现致命错误.无法完成矩形的最终绘制.
哪位大哥可以帮小弟看看是什么原因.

拖放结束后出现: Unhandled Expception C0000005(Access Violation Reading Ox0054)at address 65462AC9h
关掉AUTCAD后 出现 :INTERNAL ERROR!XCOMMAND.cpp@3337:Was Open For Write
代码如下:

class CMARectWindow : public AcDbEntity
{
public:

ACRX_DECLARE_MEMBERS(CMARectWindow);
CMARectWindow();
virtual ~CMARectWindow();
virtual Acad::ErrorStatus dwgOutFields(AcDbDwgFiler* pFiler) const;
virtual Acad::ErrorStatus dwgInFields(AcDbDwgFiler* pFiler);
virtual Acad::ErrorStatus dxfInFields(AcDbDxfFiler* pFiler);
virtual Acad::ErrorStatus dxfOutFields(AcDbDxfFiler* pFiler)const;
virtual Acad::ErrorStatus getGripPoints(AcGePoint3dArray& gripPoints, AcDbIntArray& osnapMasks, AcDbIntArray& geomIds) const;
virtual Acad::ErrorStatus moveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset);
virtual Adesk::Boolean worldDraw(AcGiWorldDraw* mode);
AcGePoint3d m_UpLeftPt;
AcGePoint3d m_DownRightPt;
AcGePoint3d m_DownLeftPt;
AcGePoint3d m_UpRightPt;
private:
};




ACRX_DXF_DEFINE_MEMBERS(CMARectWindow, AcDbEntity,
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
0,
CUSTOMENTITY, /*MSG0*/AutoCAD);


CMARectWindow::CMARectWindow()
{

}

CMARectWindow::~CMARectWindow()
{}

Acad::ErrorStatus CMARectWindow::getGripPoints(AcGePoint3dArray& gripPoints, AcDbIntArray& osnapMasks, AcDbIntArray& geomIds)const
{
assertReadEnabled();
AcGePoint3d um,lm,rm,bm;
um=m_UpLeftPt+0.5*(m_UpRightPt-m_UpLeftPt);
lm=m_DownLeftPt+0.5*(m_UpLeftPt-m_DownLeftPt);
rm=m_DownRightPt+0.5*(m_UpRightPt-m_DownRightPt);
bm=m_DownLeftPt+0.5*(m_DownRightPt-m_DownLeftPt);
gripPoints.append(um);
gripPoints.append(rm);
gripPoints.append(bm);
gripPoints.append(lm);
return Acad::eOk;
}
Acad::ErrorStatus CMARectWindow::moveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset)
{
assertWriteEnabled();
switch(indices[0]) {
case 0:
m_UpLeftPt[Y]+=offset.y;
m_UpRightPt[Y]+=offset.y;
break;
case 1:
m_UpRightPt[X]+=offset.x;
m_DownRightPt[X]+=offset.y;
break;
case 2:
m_DownLeftPt[Y]-=offset.y;
m_DownRightPt[Y]-=offset.y;
break;
case 3:
m_DownLeftPt[X]-=offset.x;
m_UpLeftPt[X]-=offset.x;
break;
default:
break;
}
return Acad::eOk;
}
Adesk::Boolean CMARectWindow::worldDraw(AcGiWorldDraw* mode)
{
assertReadEnabled();

m_DownLeftPt[0]=m_UpLeftPt[0];
m_DownLeftPt[1]=m_DownRightPt[1];
m_DownLeftPt[2]=0;
m_UpRightPt[0]=m_DownRightPt[0];
m_UpRightPt[1]=m_UpLeftPt[1];
m_UpRightPt[2]=0;
AcGePoint3d pLineArray[5];
pLineArray[0] =m_UpLeftPt;
pLineArray[1] =m_UpRightPt;
pLineArray[2] =m_DownRightPt;
pLineArray[3] =m_DownLeftPt;
pLineArray[4] =m_UpLeftPt;
mode->geometry().polyline(5, pLineArray);

return Adesk::kTrue;
}

Acad::ErrorStatus CMARectWindow::dwgInFields(AcDbDwgFiler* pFiler)
{
assertWriteEnabled();

Acad::ErrorStatus es;
if ((es = AcDbEntity::dwgInFields(pFiler)) != Acad::eOk)
{
return es;
}

pFiler->readItem(&m_UpLeftPt);
pFiler->readItem(&m_DownRightPt);
pFiler->readItem(&m_DownLeftPt);
pFiler->readItem(&m_UpRightPt);
return pFiler->filerStatus();
}

Acad::ErrorStatus CMARectWindow::dwgOutFields(AcDbDwgFiler* pFiler) const
{
assertReadEnabled();

Acad::ErrorStatus es;
if ((es = AcDbEntity::dwgOutFields(pFiler)) != Acad::eOk)
{
return es;
}

pFiler->writeItem(m_UpLeftPt);
pFiler->writeItem(m_DownRightPt);
pFiler->writeItem(m_UpRightPt);
pFiler->writeItem(m_DownLeftPt);
return pFiler->filerStatus();
}

Acad::ErrorStatus CMARectWindow::dxfInFields(AcDbDxfFiler* pFiler)
{
assertWriteEnabled();
Acad::ErrorStatus es=Acad::eOk;
resbuf rb;
if ((AcDbEntity::dxfInFields(pFiler)!=Acad::eOk)||!pFiler->atSubclassData("CMARectWindow"))
{
return pFiler->filerStatus();
}
AcGePoint3d ulPt,urPt,dlPt,drPt;
while ((es==Acad::eOk)&&(es=pFiler->readResBuf(&rb))==Acad::eOk)
{
switch(rb.restype) {
case kDxfXCoord:
ulPt=asPnt3d(rb.resval.rpoint);
break;
case kDxfXCoord+1:
urPt=asPnt3d(rb.resval.rpoint);
break;
case kDxfXCoord+2:
dlPt=asPnt3d(rb.resval.rpoint);
break;
case kDxfXCoord+3:
drPt=asPnt3d(rb.resval.rpoint);
break;
default:
pFiler->pushBackItem();
es=Acad::eEndOfFile;
break;
}
}
if (es!=Acad::eEndOfFile)
{
return Acad::eInvalidResBuf;
}
return es;

}

Acad::ErrorStatus CMARectWindow::dxfOutFields(AcDbDxfFiler* pFiler) const
{
assertReadEnabled();
Acad::ErrorStatus es;
if ((es=AcDbEntity::dxfOutFields(pFiler))!=Acad::eOk)
{
return es;
}
pFiler->writeItem(AcDb::kDxfSubclass,"CMARectWindow");
pFiler->writeItem(AcDb::kDxfXCoord,m_UpLeftPt);
pFiler->writeItem(AcDb::kDxfXCoord+1,m_UpRightPt);
pFiler->writeItem(AcDb::kDxfXCoord+2,m_DownRightPt);
pFiler->writeItem(AcDb::kDxfXCoord+3,m_DownLeftPt);
return es;
}
class AsdkRectJig:public AcEdJig
{
public:
AsdkRectJig(AcGePoint3d &);
void doIt();
virtual DragStatus sampler();
virtual Adesk::Boolean update();
virtual AcDbEntity* entity() const;
protected:
private:
CMARectWindow *mpRect;
AcGePoint3d mUpLeftPt,mDownRightPt;
double m_length,m_height;
AcGeVector3d mNormal;
};

AsdkRectJig::AsdkRectJig(AcGePoint3d &t)
{
mpRect=new CMARectWindow();
mpRect->m_UpLeftPt=Pt;
}

void AsdkRectJig::doIt()
{

setDispPrompt("\nRect choose the second point:");
AcEdJig::DragStatus stat=drag();
append();

}

AcEdJig::DragStatus
AsdkRectJig::sampler()
{
DragStatus stat;
setUserInputControls((UserInputControls)
(AcEdJig::kGovernedByOrthoMode
|AcEdJig::kAccept3dCoordinates
|AcEdJig::kNoNegativeResponseAccepted
|AcEdJig::kNoZeroResponseAccepted));
static AcGePoint3d axispointTemp;
stat=acquirePoint(mDownRightPt);
if (axispointTemp!=mDownRightPt)
{
axispointTemp=mDownRightPt;
}
else if(stat==AcEdJig::kNormal)
{
return AcEdJig::kNoChange;
}
return stat;
}

Adesk::Boolean
AsdkRectJig::update()
{
mpRect->m_DownRightPt=mDownRightPt;
return Adesk::kTrue;
}

AcDbEntity *
AsdkRectJig::entity() const
{
return mpRect;
}

// This is command 'REC'
void studyrectrec()
{
// TODO: Implement the command
AcGePoint3d tempPt;
struct resbuf rbFrom,rbTo;
ads_getpoint(NULL,"\nRect choose the first point:",asDblArray(tempPt));
rbFrom.restype=RTSHORT;
rbFrom.resval.rint=1;
rbTo.restype=RTSHORT;
rbTo.resval.rint=0;
ads_trans(asDblArray(tempPt),&rbFrom,&rbTo,Adesk::kFalse,asDblArray(tempPt));
AsdkRectJig *pJig=new AsdkRectJig(tempPt);
pJig->doIt();
delete pJig;
}
发表于 2006-8-31 17:17:00 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2006-9-8 20:10:00 | 显示全部楼层

我的程序也是这样

我拖动的是一个BlockReference,当我第一次拖动的时候没有问题

但是当我又创建一个Reference的时候当我拖动的时候就会出现上面所说的UnHandled这样的错误提示

发表于 2006-9-8 23:37:00 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2006-9-11 09:42:00 | 显示全部楼层

呵呵 `兄弟真是太谢谢你了,请问兄弟有没有联系方式?QQ ??

请问可不可以连续拖动,并且给所拖动的实体 加上自定义属性

我现在有个程序出现这样的毛病,当拖动一个块引用的时候,拖动完添加到数据库中,然后为该实体添加属性(因为我看到ARX帮助上写的添加属性只能是为数据库常驻实体添加,当一个实体还没有保存到数据库中会出现eNoDatabase这样的情况)

当第一次创建一个块引用,然后设置属性的时候没有问题,但是我要是把这段拖动添加属性的程序放在一个循环里就会出现问题,也就是说,当循环第一次的时候没有问题,但是当循环第二次的时候,就会出现Unhandled错误(出现在jig->drag()处),当我尝试不放在循环里,一次创建一个实体,没有 问题,当我尝试放在循环中但是不添加属性也没有问题~~

这个毛病困扰 我一个星期了~~,请楼上的兄弟帮忙分析是怎么回事,好么??

我QQ:27176970

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 21:50 , Processed in 0.167277 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表