以下示例演示如何实例化 xrecord 并将其添加到命名对象字典中的扩展字典中: void createXrecord() { AcDbXrecord *pXrec = new AcDbXrecord; AcDbObject *pObj; AcDbObjectId dictObjId, xrecObjId; AcDbDictionary* pDict; pObj = selectObject(AcDb::kForWrite); if (pObj == NULL) { return; } // Try to create an extension dictionary for this // object. If the extension dictionary already exists, // this will be a no-op. // pObj->createExtensionDictionary(); // Get the object ID of the extension dictionary for the // selected object. // dictObjId = pObj->extensionDictionary(); pObj->close(); // Open the extension dictionary and add the new // xrecord to it. // acdbOpenObject(pDict, dictObjId, AcDb::kForWrite); pDict->setAt("ASDK_XREC1", pXrec, xrecObjId); pDict->close(); // Create a resbuf list to add to the xrecord. // struct resbuf* head; ads_point testpt = {1.0, 2.0, 0.0}; head = acutBuildList(AcDb::kDxfText, "This is a test Xrecord list", AcDb::kDxfXCoord, testpt, AcDb::kDxfReal, 3.14159, AcDb::kDxfAngle, 3.14159, AcDb::kDxfColor, 1, AcDb::kDxfInt16, 180, 0); // Add the data list to the xrecord. Notice that this // member function takes a reference to a resbuf NOT a // pointer to a resbuf, so you must dereference the // pointer before sending it. // pXrec->setFromRbChain(*head); pXrec->close(); acutRelRb(head); } // The listXrecord() function gets the xrecord associated with the // key "ASDK_XREC1" and lists out its contents by passing the resbuf // list to the function printList(). // void listXrecord() { AcDbObject *pObj; AcDbXrecord *pXrec; AcDbObjectId dictObjId; AcDbDictionary *pDict; pObj = selectObject(AcDb::kForRead); if (pObj == NULL) { return; } // Get the object ID of the object's extension dictionary. // dictObjId = pObj->extensionDictionary(); pObj->close(); // Open the extension dictionary and get the xrecord // associated with the key ASDK_XREC1. // acdbOpenObject(pDict, dictObjId, AcDb::kForRead); pDict->getAt("ASDK_XREC1", (AcDbObject*&)pXrec, AcDb::kForRead); pDict->close(); // Get the xrecord's data list and then close the xrecord. // struct resbuf *pRbList; pXrec->rbChain(&pRbList); pXrec->close(); printList(pRbList); acutRelRb(pRbList); } |
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1 )
GMT+8, 2024-6-11 04:03
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.