马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- AcDbObjectId cloneBlockRecord(AcDbObjectId from, char *to)
- {
- AcDbBlockTable *pBlockTable;
- AcDbBlockTableRecord *pBlockTableRecord;
- AcGePoint3d tempOrigin;
- AcDbObjectIdArray arrayId;
- AcDbBlockTableRecordIterator *pIter;
- AcDbObjectId objId, tableId, blockTargetId;
- AcDbDatabase *pDB;
- AcDbIdMapping idMap;
- char buffer[21];
- pDB = acdbHostApplicationServices()->workingDatabase();
- acdbOpenAcDbObject ((AcDbObject *&)pBlockTableRecord, from,
- AcDb::kForRead);
- tempOrigin = pBlockTableRecord->origin();
- pBlockTableRecord->newIterator(pIter);
- while (!pIter->done())
- {
- pIter->getEntityId(objId);
- arrayId.append(objId);
- pIter->step();
- }
- delete pIter ;
- tableId = pBlockTableRecord->ownerId();
- pBlockTableRecord->close();
- pDB->getBlockTable(pBlockTable, AcDb::kForRead);
- strcpy(buffer, to);
- if(pBlockTable->has(buffer))
- {
- for (int i = 0; i < 255; i++)
- {
- sprintf(buffer, "%s%d", to, i);
- if(!pBlockTable->has(buffer))
- {
- break;
- }
- }
- }
- pBlockTable->upgradeOpen ();
- pBlockTableRecord = new AcDbBlockTableRecord;
- pBlockTableRecord->setName(buffer);
- pBlockTableRecord->setOrigin(tempOrigin);
- pBlockTable->add(blockTargetId, pBlockTableRecord);
- pBlockTableRecord->close();
- pBlockTable->close();
- pDB->deepCloneObjects(arrayId, blockTargetId, idMap);
- return blockTargetId;
- }
|