}
// Check if we’re at the right subclass getData marker.
//
if (!pFiler->atSubclassData("AsdkMyClass")) {
return Acad::eBadDxfSequence;
}
struct resbuf inbuf;
while (es == Acad::eOk) {
if ((es = pFiler->readItem(&inbuf)) == Acad::eOk) {
if (inbuf.restype == AcDb::kDxfInt16) {
mIntval = inbuf.resval.rint;
}
}
}
return pFiler->filerStatus();
}
// Files data out to a DXF file.
//
Acad::ErrorStatus
AsdkMyClass::dxfOutFields(AcDbDxfFiler* pFiler) const
{
assertReadEnabled();
AcDbObject::dxfOutFields(pFiler);
pFiler->writeItem(AcDb::kDxfSubclass, "AsdkMyClass");
pFiler->writeItem(AcDb::kDxfInt16, mIntval);
return pFiler->filerStatus();
}
// This function creates two objects of class AsdkMyClass.
// It fills them in with the integers 1 and 2, and then adds
// them to the dictionary associated with the key ASDK_DICT.
// If this dictionary doesn’t exist, it is created and added
// to the named object dictionary.
//
void
createDictionary()
{
AcDbDictionary *pNamedobj;
acdbHostApplicationServices()->workingDatabase()->
getNamedObjectsDictionary(pNamedobj, AcDb::kForWrite);
// Check to see if the dictionary we want to create is
// already present. If not, create it and add
// it to the named object dictionary.
//
AcDbDictionary *pDict;
if (pNamedobj->getAt("ASDK_DICT", (AcDbObject*&) pDict,
AcDb::kForWrite) == Acad::eKeyNotFound)
{
pDict = new AcDbDictionary;
AcDbObjectId DictId;
pNamedobj->setAt("ASDK_DICT", pDict, DictId);
}
pNamedobj->close();
if (pDict) {
// Create new objects to add to the new dictionary,
// add them, then close them.
//
AsdkMyClass *pObj1 = new AsdkMyClass(1);
AsdkMyClass *pObj2 = new AsdkMyClass(2);
AcDbObjectId rId1, rId2;
pDict->setAt("OBJ1", pObj1, rId1);
pDict->setAt("OBJ2", pObj2, rId2);
pObj1->close();
pObj2->close();
pDict->close();
}
}
// Opens the dictionary associated with the key ASDK_DICT