- UID
- 252215
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2005-4-29
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2005-5-30 13:42:18
|
显示全部楼层
根据2楼的说法我写了如下代码
//////////////////读出所有的对象//////////////////////////////
bool getAllEntity(AcDbObjectIdArray& IdArr)
{
Acad::ErrorStatus es=Acad::eOk;
ads_name ssname;
ads_name fname;
if (acdbEntNext(NULL, fname) != RTNORM)
{
acdbFail("No entities in drawing\n");
return (0);
}
if (acedSSGet(NULL,NULL,NULL,NULL,ssname) !=RTNORM)
{
ads_alert("acedSSGet失败");
return (0);
}
long ilast;
if (acedSSLength(ssname, &ilast) != RTNORM)
{
acedSSFree(ssname);
return (0);
}
AcDbObjectId Idtemp;
ads_name ntemp;
for (long i=0;i<ilast;i++)
{
ads_alert("1");
acedSSName(ntemp,i,ssname);
acdbGetObjectId(Idtemp,ntemp);
IdArr.append(Idtemp);
}
acedSSFree(ssname);
// acutPrintf("eend");
return (1);
}
////////////////////////// 节点的搜寻////////////////
//////////////////////////////////读点///////////////////////////
bool getAllPoints(AcDbObjectIdArray& IdArr, AcGePoint3dArray& pntArr)
{
AcDbObjectId objId;
for (int i=0 ; i<IdArr.length();i++)
{
AcDbObject *SelEnt;
objId=IdArr.at(i);
acdbOpenObject(SelEnt, objId,AcDb::kForRead);
if (SelEnt->isKindOf(AcDbLine::desc()))
{
ads_alert("line");
SelEnt->close();
pLine(objId,pntArr);
break;
}
else
if (SelEnt->isKindOf(AcDbPolyline::desc()))
{
ads_alert("poly");
SelEnt->close();
pPolyLine(objId,pntArr);
break;
}
else
if (SelEnt->isKindOf(AcDbCurve::desc()))
{
ads_alert("curve");
SelEnt->close();
collectVertices(objId,pntArr);
break;
}
else
{
ads_alert("不能识别的类型进入");
ads_fail("不能识别的类型");
SelEnt->close();
return (0);
}
}
return (1);
}
//////////////////////////椭圆,半圆,曲线等//////////////////////
void collectVertices( AcDbObjectId& ellipseId, AcGePoint3dArray& pts)
{
AcDbCurve *pEllipse;
acdbOpenObject(pEllipse, ellipseId, AcDb::kForRead);
if (pEllipse->isClosed())
{
pEllipse->close();
return;
}
AcGePoint3d temp;
pEllipse->getEndPoint(temp);
pts.append(temp);
pEllipse->getStartPoint(temp);
pts.append(temp);
pEllipse->close();
//AcDbObjectId newCurveId;
//addToModelSpace(newCurveId, pProjectedCurve);
}
///////////////////////多义线/////////////////////
void pPolyLine( AcDbObjectId plineId, AcGePoint3dArray& pts)
{
AcDb2dPolyline *pPline;
acdbOpenObject (pPline,plineId,AcDb::kForRead);
if (pPline->isClosed())
{
pPline->close();
return;
}
AcDbObjectIterator *pVertIter=pPline->vertexIterator();
pPline->close();
AcDb2dVertex *pVertex;
AcGePoint3d location;
AcDbObjectId vertexObjId;
for (int vertexNumber = 0;!pVertIter->done();
vertexNumber++,pVertIter->step())
{
vertexObjId = pVertIter->objectId();
acdbOpenObject (pVertex,vertexObjId,AcDb::kForRead);
location = pVertex->position();
pVertex->close();
pts.append(location);
}
delete pVertIter;
}
//////////////////////////////直线//////////////////
void pLine( AcDbObjectId LineId, AcGePoint3dArray& pts)
{
AcDbLine *pLine;
acdbOpenObject (pLine,LineId,AcDb::kForRead);
AcGePoint3d location = pLine->startPoint() ;
pts.append(location);
location = pLine->endPoint() ;
pts.append(location);
pLine->close();
}
但是死活 在读点的acdbOpenObject(SelEnt, objId,AcDb::kForRead);之后出错
信息是什么 未处理异常 C0000005((ACCESS Violation Reading 0xcccccccc), |
|