当前位置: 首页>>代码示例>>C++>>正文


C++ AcDbObject::createExtensionDictionary方法代码示例

本文整理汇总了C++中AcDbObject::createExtensionDictionary方法的典型用法代码示例。如果您正苦于以下问题:C++ AcDbObject::createExtensionDictionary方法的具体用法?C++ AcDbObject::createExtensionDictionary怎么用?C++ AcDbObject::createExtensionDictionary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AcDbObject的用法示例。


在下文中一共展示了AcDbObject::createExtensionDictionary方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: selectObject

// The createXrecord() functions creates an xrecord object, 
// adds data to it, and then adds the xrecord to the extension 
// dictionary of a user selected object.
// 
// THE FOLLOWING CODE APPEARS IN THE SDK DOCUMENT.
//
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);
}
开发者ID:kevinzhwl,项目名称:ObjectARXMod,代码行数:60,代码来源:xtsndict.cpp

示例2: GetExtensionDict

AcDbObjectId ArxDictTool::GetExtensionDict( const AcDbObjectId& objId )
{
    AcTransaction* pTrans = actrTransactionManager->startTransaction();
    if( pTrans == 0 ) return AcDbObjectId::kNull;

    AcDbObject* pObj;
    if( Acad::eOk != pTrans->getObject( pObj, objId, AcDb::kForWrite ) )
    {
        actrTransactionManager->abortTransaction();
        return AcDbObjectId::kNull;
    }

    AcDbObjectId dictId = pObj->extensionDictionary();
    if( dictId.isNull() )
    {
        if( Acad::eOk == pObj->createExtensionDictionary() )
        {
            dictId = pObj->extensionDictionary();
        }
    }
    actrTransactionManager->endTransaction();

    return dictId;
}
开发者ID:hunanhd,项目名称:cbm,代码行数:24,代码来源:ArxDictTool.cpp

示例3: addEmpCommand

void addEmpCommand()
{ 
    AcDbDictionary* pEmployeeDict=NULL;
    EmployeeDetails* pEmployeeDetails=NULL;
    EmployeeEntry* pEmployeeEntry=NULL;
    //this cannot really happen but...
    if (acdbHostApplicationServices()->workingDatabase()==NULL)
        return;
    try
    {
        //start transaction for the db operations in this command
        actrTransactionManager->startTransaction();

        //get the data from the user
        ads_name ename;
        ads_point pt;
        ADSOK(acedEntSel("Select employee:",ename,pt));

        //do a quick check
        //a more comprehensive check could include 
        //a check to see if we already have the detail object on this candidate
        AcDbObjectId idO;
        ARXOK(acdbGetObjectId(idO,ename));
        AcDbObject* pO;
        ARXOK(actrTransactionManager->getObject(pO,idO,AcDb::kForWrite));
        if (!pO->isKindOf(AcDbBlockReference::desc()))
            throw Acad::eNotThatKindOfClass;

        //go on getting user input
        int id;
        ADSOK(acedGetInt("Enter employee ID:",&id));

        int cubeNumber;
        ADSOK(acedGetInt("Enter cube number:",&cubeNumber));

        char strFirstName[133];
        ADSOK(acedGetString(0,"Enter employee first name:",strFirstName));

        char strLastName[133];
        ADSOK(acedGetString(0,"Enter employee last name:",strLastName));
        
        //create an EmployeeDetails object and set its fields
        if ((pEmployeeDetails= new EmployeeDetails)==NULL)
            throw Acad::eOutOfMemory;
        ARXOK(pEmployeeDetails->setID(id));
        ARXOK(pEmployeeDetails->setCubeNumber(cubeNumber));
        ARXOK(pEmployeeDetails->setFirstName(strFirstName));
        ARXOK(pEmployeeDetails->setLastName(strLastName));

        //get hold of the extension dictionary
        if ((idO = pO->extensionDictionary())==AcDbObjectId::kNull){
            ARXOK(pO->createExtensionDictionary());
            idO = pO->extensionDictionary();
        }
        AcDbDictionary* pExtDict;
        //make sure you open erased extension dictionaries
        //you may need to unerase them
        ARXOK(actrTransactionManager->getObject((AcDbObject*&)pExtDict,idO,AcDb::kForWrite,Adesk::kTrue));
        
        //add the EmployeeDetails to the extension dictionary
        addDictAndEntry(DICT,pExtDict,DETAILS,pEmployeeDetails);
        
        //create the EmployeeEntry and set the id it holds to
        //point to the corresponding EmployeeDetails
        if ((pEmployeeEntry= new EmployeeEntry)==NULL)
            throw Acad::eOutOfMemory;
        ARXOK(pEmployeeEntry->setEmployee(pEmployeeDetails->objectId()));

        //get hold of the NOD
        AcDbDictionary* pNOD;
		ARXOK(getNOD(pNOD,AcDb::kForWrite));
        
        //create string key from the employee id
        char strID[33];
        sprintf(strID,"%d",id);

        //set the EmployeeEntry to the NOD
        addDictAndEntry(DICT,pNOD,strID,pEmployeeEntry);

        actrTransactionManager->endTransaction();
    }
    catch (const Acad::ErrorStatus es)
    {
        //we have run into some error
        //do the proper cleanup. a smart pointer could check these in its
        //destructor and then we wouldn't need this but we I don't want to
        //complicate the picture with that yet.
        if (pEmployeeDict!=NULL && 
            pEmployeeDict->objectId()==AcDbObjectId::kNull)
            delete pEmployeeDict;
        if (pEmployeeDetails!=NULL && 
            pEmployeeDetails->objectId()==AcDbObjectId::kNull)
            delete pEmployeeDetails;
        if (pEmployeeEntry!=NULL && 
            pEmployeeEntry->objectId()==AcDbObjectId::kNull)
            delete pEmployeeEntry;
        //abort, rollback all db operations
        actrTransactionManager->abortTransaction();
        //check if the user has cancelled us, then we don't report
        //anything
//.........这里部分代码省略.........
开发者ID:kevinzhwl,项目名称:ObjectARXMod,代码行数:101,代码来源:lab6commandmain.cpp


注:本文中的AcDbObject::createExtensionDictionary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。