ObjectARX, AutoCAD. Среда программирования библиотеки C++




Словарь имен объектов - часть 3


// means that the destination drawing may already

// have our dictionary, in which case we have to

// merge our entries into the destination

// dictionary. First we must find out if

// the destination named objects dictionary contains

// our dictionary.

//

AcDbDictionary *pDestNamedDict;

pTo->getNamedObjectsDictionary(pDestNamedDict, AcDb::kForWrite);

// Since INSERT does not clone the destination

// named object dictionary, we can use getAt()

// on it.

//

es = pDestNamedDict->getAt(kpDictionary, dictId);

// If our dictionary does not yet exist in the

// named object dictionary, which is not itself

// cloned, we have to both clone and add our

// dictionary to it. Since dictionary entries are

// ownership references, all of our entries will

// also be cloned at this point, so we are done.

//

if (es == Acad::eKeyNotFound) {

pClone = NULL;

pSrcDict->deepClone(pDestNamedDict, pClone, idMap);

// Unless we have overridden the deepClone()

// of our dictionary, we should expect it to

// always be cloned here.

//

if (pClone == NULL) {

*pRetStat = Acad::eNullObjectId;

break;

}

pDestNamedDict->setAt(kpDictionary, pClone, dictId);

pDestNamedDict->close();

pClone->close();

break;

}

pDestNamedDict->close();

// Our dictionary already exists in the destination

// database, so now we must "merge" the entries

// into it. Since we have not cloned our

// destination dictionary, its object IDs are not in

// flux, and we can use getAt() and setAt() on it.

//

AcDbDictionary *pDestDict;

acdbOpenObject(pDestDict, dictId, AcDb::kForWrite);

AcDbObject *pObj, *pObjClone;

AcDbDictionaryIterator* pIter;

pIter = pSrcDict->newIterator();

for (; !pIter->done(); pIter->next()) {

const char *pName = pIter->name();

pIter->getObject(pObj, AcDb::kForRead);

// If the dictionary contains any references

// and/or other objects have references to it,

// you must either use deepClone() or put the

// ID pairs into the ID map here, so that they




Содержание  Назад  Вперед