- 积分
- 692
- 明经币
- 个
- 注册时间
- 2004-6-4
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
我编的打断线条的代码,为了测试,再求出交点后,在交点位置生成acdbtext,显示交点序号。命令执行后,如果删除生成的文字,AutoCAD就会出现 scran.cpp!eHadMultipltReader的错误,然后死掉。请教高手到底是啥子问题。
代码如下:
Acad::ErrorStatus TOMbreakEnt(ads_name entSrc,ads_name entDis,int &intersectNum) { AcDbEntity *pEntSrc,*pEntDis; AcDbObjectId idSrc,idDis; if (entSrc[0]==entDis[0] && entSrc[1]==entDis[1]) return Acad::eInetUnknownError; if (acdbGetObjectId(idDis,entDis)!=Acad::eOk) return Acad::eInetUnknownError; if (acdbOpenObject(pEntDis,idDis,AcDb::kForRead)!=Acad::eOk) return Acad::eInetUnknownError; if (!pEntDis->isKindOf(AcDbCurve::desc()) ) return Acad::eInetUnknownError;
if (acdbGetObjectId(idSrc,entSrc)!=Acad::eOk) return Acad::eInetUnknownError; if (acdbOpenObject(pEntSrc,idSrc,AcDb::kForRead)!=Acad::eOk) return Acad::eInetUnknownError;
AcGePoint3dArray aIntersect; AcGePoint3d or(0,0,0); AcGeVector3d vx(1,0,0),vy(0,1,0); AcGePlane pl(or,vx,vy); ads_name entLast; ads_point p1; //pEntDis->intersectWith(pEntSrc,AcDb::kOnBothOperands,pl,aIntersect); pEntSrc->intersectWith(pEntDis,AcDb::kOnBothOperands,pl,aIntersect); pEntSrc->close(); pEntDis->close(); if (aIntersect.length()>intersectNum) intersectNum=aIntersect.length(); AcDbText *pText; char text[100]; if (!aIntersect.isEmpty()){ for (long i=aIntersect.length()-1;i>=0;i--){ p1[X]=(aIntersect)[X]; p1[Y]=(aIntersect)[Y]; p1[Z]=(aIntersect)[Z]; acedCommand(RTSTR,"_break",RTLB, RTENAME, entDis, RTPOINT, p1, RTLE,RTPOINT,p1,RTNONE);
//测试用代码,如果把文字的插入点改为一样的,比如AcGePoint3d point1
//pText=new AcDbText(point1,text,AcDbObjectId::kNull,1,0)就不会出错了 sprintf(text,"%d",i); pText=new AcDbText(aIntersect,text,AcDbObjectId::kNull,1,0); AddEntity(pText); pText->close(); } } return Acad::eOk; }
|
|