- UID
- 17363
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-11-27
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
我想把block分解成一般的实体,可当对打散实体操作时总是出错不知为什么,请大家指教。
下面代码是其中的一部分,当调用函数extract()提取三维线的顶点时
es=p3DPL->openVertex(pVertex,ID,AcDb::kForRead,Adesk::kTrue);的返回值es总是Acad::eNullObjectId不知是什么原因?
void getBlockInfo()
{
AcDbBlockTable *pBlkTbl;
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlkTbl, AcDb::kForRead);
AcDbBlockTableRecord *pBlkTblRcd;
pBlkTbl->getAt(ACDB_MODEL_SPACE, pBlkTblRcd, AcDb::kForRead);
pBlkTbl->close();
AcDbBlockTableRecordIterator *pBlkTblRcdItr;
pBlkTblRcd->newIterator(pBlkTblRcdItr);
AcDbEntity *pEnt;
AcGePoint3dArray ptArray;
int nNum,nColor=1,i;
const char *objName;
for (pBlkTblRcdItr->start(); !pBlkTblRcdItr->done();pBlkTblRcdItr->step())
{
pBlkTblRcdItr->getEntity(pEnt, AcDb::kForRead);
objName=pEnt->isA()->name();
if(!stricmp(objName,"AcDbBlockReference"))
{
AcDbVoidPtrArray entitySet;
AcDbEntity *pEntTmp;
pEnt->explode(entitySet);
//分解block(由三维线和一个圆组成)块
int n=entitySet.length();
for(i=0;i<n;i++)
{
pEntTmp=(AcDbEntity *)entitySet;
//提取三维线顶点坐标
if(extract(pEntTmp,ptArray))
{}
}
}
pEnt->close();
}
pBlkTblRcd->close();
delete pBlkTblRcdItr;
}
BOOL extract(AcDbEntity *pEntity,AcGePoint3dArray &pointArray)
{
const char *objName;
if (pEntity==NULL)return false;
AcGePoint3d pt;
objName=pEntity->isA()->name();
pointArray.setLogicalLength(0);
if(!stricmp(objName,"AcDb3dPolyline"))
{
AcDb3dPolylineVertex *pVertex = NULL;
AcDbObjectId ID;
AcDb3dPolyline *p3DPL = (AcDb3dPolyline*)pEntity;
AcDbObjectIterator * pIter;
Acad::ErrorStatus es ;
pIter = p3DPL->vertexIterator();
for (;!pIter->done();pIter->step())
{
ID=pIter->objectId();
es=p3DPL->openVertex(pVertex,ID,AcDb::kForRead,Adesk::kTrue);
if(Acad::eOk!=es)continue;
pt=pVertex->position();
pointArray.append(pt);
pVertex->close();
}
delete pIter;
}
else if(pEntity->isA()==AcDbCircle::desc())
{
}
else
{
}
return true;
} |
|