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


s not appropriate because it

// itself, but that’ s not appropriate because it would clutter

// up the named object dictionary.





AcDbObjectId objIdA, objIdB, objIdC;

AcDbDictionary *pNamedobj;

AcDbDictionary *pDict = NULL;

AcDbDatabase *pCurDwg = acdbHostApplicationServices()->workingDatabase();

// Create object C with a dummy integer data value of 3.


AsdkOwnerDemo *pObjC = new AsdkOwnerDemo(3);

// Append object C to database without setting an owner.


pCurDwg->addAcDbObject(objIdC, pObjC);


// Create object B with a dummy integer data value of 2.


AsdkOwnerDemo *pObjB = new AsdkOwnerDemo(2);

// Append object B to the database without setting an owner.


pCurDwg->addAcDbObject(objIdB, pObjB);

// Now set up ownership for object C. The

// AsdkOwnerDemo::setIdData() function takes the

// objectId parameter and copies it into the

// AcDbHardOwnershipId data member. This places the

// object ID in a position to be filed out/in via the

// dwgInFields/dwgOutFields/dxfInFields/dxfOutFields

// member functions. This constitutes primary

// "ownership." The AsdkOwnerDemo::setIdData() function

// also calls each owned object’s setOwnerId() member

// function to set the backpointer and establish the

// full two-way ownership link.




// Create object A with a dummy integer data value of 1.


AsdkOwnerDemo *pObjA = new AsdkOwnerDemo(1);

// Next, add objA to a dictionary in the named object

// dictionary. This will establish ownership for objA,

// set the ownership backlink, and add it to the

// database.


pCurDwg->getNamedObjectsDictionary(pNamedobj, AcDb::kForWrite);

// Get a pointer to the ASDK_DICT dictionary. If it

// doesn’t exist, then create it and add it to the

// named object dictionary.


if (pNamedobj->getAt("ASDK_DICT", (AcDbObject*&) pDict,

AcDb::kForWrite) == Acad::eKeyNotFound)


pDict = new AcDbDictionary;

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