Community
Hi,
I'm facing an issue when I wblockCloneObjects a AcDbMLeaderStyle, when style already exist in destination database. Here's my code:
AcDbDatabase * pDatabaseSource = new AcDbDatabase(false, true); if((es = pDatabaseSource->readDwgFile(_T("path to dwg"), AcDbDatabase::kForReadAndAllShare)) == Acad::eOk) { //retrieve in source dwg AcDbObjectId idLeaderStyleSource = AcDbObjectId::kNull; AcDbDictionary * pDictionarySource = NULL; if(pDatabaseSource->getMLeaderStyleDictionary(pDictionarySource, AcDb::kForRead) == Acad::eOk) { if(pDictionarySource->has(_T("myleaderstyle"))) pDictionarySource->getAt(_T("myleaderstyle"), idLeaderStyleSource); pDictionarySource->close(); } //if source mleader style found => clone AcDbObjectPointer<AcDbMLeaderStyle> pLeaderStyleSource(idLeaderStyleSource, AcDb::kForRead); if((es = pLeaderStyleSource.openStatus()) == Acad::eOk) { AcDbIdMapping idMap; idMap.setDestDb(pDatabase); AcDbObjectIdArray ids; ids.append(idLeaderStyleSource); if((es = pDatabaseSource->wblockCloneObjects(ids, pDatabase->mleaderStyleDictionaryId(), idMap, AcDb::kDrcReplace)) == Acad::eOk) { //loop on cloned object int iIdx = -1; AcDbIdPair idPair; AcDbIdMappingIter iter(idMap); for(iter.start(); !iter.done(); iter.next()) { if(!iter.getMap(idPair)) continue; if(idPair.key() != idLeaderStyleSource) continue; AcDbObjectPointer<AcDbMLeaderStyle> pLeaderStyle(idPair.value(), AcDb::kForWrite); if((es = pLeaderStyle.openStatus()) != Acad::eOk) continue; //... } } } } delete pDatabaseSource;
If the style doesn't exist in destination database, it will create it correctly. Otherwise, the code runs correctly, but the values of the existing style are not updated. And I don't know why! I use similar code to "import" AcDbDimStyle and everything works like a charm.
Any suggestions are welcomed.
Regards,