wblockCloneObjects从块定义写块到外部文件
作者:互联网
wblockCloneObjects从块定义写块到外部文件简单例子
AcDbObjectIdArray objIds; ads_name ent; ads_point pt; if (RTNORM != acedEntSel(_T("\n选择一个块参照对象:"),ent,pt)) { acutPrintf(_T("\n未选择有效对象!")); return; } AcDbObjectId objId; acdbGetObjectId(objId,ent); AcDbObjectPointer<AcDbBlockReference> pBlkRef(objId,AcDb::kForRead); if (Acad::eOk != pBlkRef.openStatus()) { acutPrintf(_T("\n未选择块参照对象!")); return; } AcDbObjectId blkId=pBlkRef->blockTableRecord(); AcDbBlockTableRecordPointer pBlkDef(blkId,AcDb::kForRead); if (Acad::eOk != pBlkDef.openStatus()) { acutPrintf(_T("\n打开块定义对象失败!")); return; } AcDbBlockTableRecordIterator *pNewItor=NULL; pBlkDef->newIterator(pNewItor); if (pNewItor==NULL) { acutPrintf(_T("\n创建块定义遍历器失败!")); return; } for (pNewItor->start();!pNewItor->done();pNewItor->step()) { AcDbObjectId entId; pNewItor->getEntityId(entId); objIds.append(entId); } delete pNewItor; if (objIds.length()<1) { acutPrintf(_T("\n块定义中没有实体对象!")); return; } AcDbDatabase *pNewDb=new AcDbDatabase(); if (pNewDb==NULL) { acutPrintf(_T("\n创建新数据库对象失败!")); return; } AcDbObjectId msId=pNewDb->currentSpaceId(); AcDbIdMapping idMap; Acad::ErrorStatus es=pNewDb->wblockCloneObjects(objIds,msId,idMap,AcDb::kDrcIgnore); if(Acad::eOk == es) { acutPrintf(_T("\n克隆成功!")); } else { acutPrintf(_T("\n克隆出错,错误码%s"),acadErrorStatusText(es)); } pNewDb->saveAs(_T("d:\\myclone.dwg")); delete pNewDb; pNewDb=NULL;
标签:acutPrintf,Acad,return,objIds,pNewDb,pNewItor,wblockCloneObjects,写块,从块 来源: https://www.cnblogs.com/edata/p/13729391.html