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


Перегрузка deepClone () Функция - часть 3

// Step 1: Create the clone.


AsdkPoly *pClone = (AsdkPoly*)isA()->create();

if (pClone != NULL)

pClonedObject = pClone; // Set the return value.


return Acad::eOutOfMemory;

// Step 2: Append the clone to its new owner. In this

// example, the original object is derived from AcDbEntity,

// so the owner is expected to be an AcDbBlockTableRecord,

// unless an ownership relationship is set up with another

// object. In that case, it is important to establish a

// connection to that owner. This sample shows a generic

// method using setOwnerId().


AcDbBlockTableRecord *pBTR =


if (pBTR != NULL) {


} else {

if (isPrimary)

return Acad::eInvalidOwnerObject;

// Some form of this code is only necessary if

// anyone has set up an ownership for the object

// other than with an AcDbBlockTableRecord.





// Step 3: Now contents are copied to the clone. This is done

// using an AcDbDeepCloneFiler. This filer keeps a list of all

// AcDbHardOwnershipIds and AcDbSoftOwnershipIds contained in

// the object and its derived classes. This list is then used

// to know what additional, "owned" objects need to be cloned

// below.


AcDbDeepCloneFiler filer;


// Step 4: Rewind the filer and read the data into the clone.


filer.seek(0L, AcDb::kSeekFromStart);


// Step 5: This must be called for all newly created objects

// in deepClone(). It is turned off by endDeepClone()

// after it has translated the references to their

// new values.



// Step 6: Add the new information to the ID map. We can use

// the ID pair started above.





// Step 7: Using the filer list created above, find and clone

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