- UID
- 9053
- 积分
- 0
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-8-22
- 最后登录
- 1970-1-1
|
楼主 |
发表于 2002-10-8 15:17:14
|
显示全部楼层
AcDbObjectIdArray mainIdArray;
AcDbObjectIdArray slaveIdArray;
// get the block table of current DWG graphic database
AcDbBlockTable *pBlkTbl= new AcDbBlockTable();
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pBlkTbl,AcDb::kForRead);
//get the block table record of model space
AcDbBlockTableRecord *pBlkTblRcd= new AcDbBlockTableRecord();
pBlkTbl->getAt(ACDB_MODEL_SPACE, pBlkTblRcd, AcDb::kForWrite);
//close the block table
pBlkTbl->close();
//create an iterator of block table record
AcDbBlockTableRecordIterator *pBlkTblRcdItr;
pBlkTblRcd->newIterator(pBlkTblRcdItr);
int number=0;
//iterator loop for block table record
for(pBlkTblRcdItr->start();!pBlkTblRcdItr->done();pBlkTblRcdItr->step())
{
//get an entity
AcDbEntity *pEnt;
pBlkTblRcdItr->getEntity(pEnt, AcDb::kForWrite);
//if the entity is AbDcline then process its startpoint and endpoint
if(pEnt->isKindOf(AcDbLine::desc()))
{
AcDbObjectId objId;
AcDbLine *pLine;
pLine=(AcDbLine*)pEnt;
Adesk::UInt16 colVal;
colVal=pLine->colorIndex();
if(colVal==1) //将红色的选为主杆
{
number++;
//objId=appendEntityToDB_1(pLine);
pBlkTblRcd->appendAcDbEntity(objId, pLine);
mainIdArray.append(objId);
}
else
{
//objId=appendEntityToDB_1(pLine);
pBlkTblRcd->appendAcDbEntity(objId, pLine);
slaveIdArray.append(objId);
}
pLine->close();
}
pEnt->close();
}//end of first for;
acutPrintf("main=%d",mainIdArray.length());
acutPrintf("\nslave=%d",slaveIdArray.length());
//close the block table record
pBlkTblRcd->close();
//delete the pointer of the iterator
delete pBlkTblRcdItr;
这就是我获取ID数组的过程,应该没有问题吧
因为acutPrintf("main=%d",mainIdArray.length());
acutPrintf("\nslave=%d",slaveIdArray.length());
都能正确的显示数组中元素的个数。 |
|