If you are creating your own ownership hierarchy, you need to set up the connection between the owner and the owned object. An object cannot have multiple owners.
The AcDbObject protocol always specifies the link from the owner to the owned object and the backward link from the object to its owner.
The following code illustrates setting up the two-way ownership link between an owner and its contents:
// Uses the OwnerDemo class defined in the next example // (see "ObjectARX Example," below). // // Sets pOwner to be the owner of pOwned. // void makeOwner(OwnerDemo* pOwner, AcDbObject* pOwned) { // First let pOwner know it is the owner. This // establishes ownership for filing persistence. // pOwner->setIdData(pOwned->ojectId()); // Now set up the backpointer so that the owned // object knows who its owner is. // pOwned->setOwnerId(pOwner->objectId()); }
Most commonly used container class members establish the two-way link automatically. For example, the following function call sets the block table record as the owner of the entity, and also adds the entity to the block table record's list of owned entities.
blockTableRecord->appendAcDbEntity( ...);
Similarly, the AcDbDictionary::setAt() function and the AcDbSymbolTable::add() function set up two-way links between the owner and its objects in one step.
If you are directly manipulating objects using (entmod) or (entmake) in AutoLISP ® , you first add the owned object to the database using (entmake), then associate its ads_name or entity name with the appropriate DXF group code in the owner object representation.