www.mxdraw.com
内容索引主面
前一个向上下一个
McDbEntity::setXData 方法

设置实体的扩展数据,扩展数据是一个链表,可以设置多个数据

C++
virtual Mcad::ErrorStatus setXData(const struct resbuf* xdata);
参数 
说明 
const struct resbuf* xdata 
扩展数据链表指针,在不使用时调用Mx::mcutRelRb释放链表 

如果成功返回Mcad::eOk

例如:sampleeditedit.sln中的例子

    void CTestCommands::WirteExData()
    {
        ads_name entName;
        ads_point pt;
        if(acedEntSel(_T("选择定义扩展数据的实体:"),entName,pt) != RTNORM)
        {
            return;
        }
        AcDbObjectId objId;
        if(acdbGetObjectId(objId,entName) != Acad::eOk)
            return;

        AcDbObjectPointer<AcDbEntity> spEnt(objId,AcDb::kForWrite);
        if(spEnt.openStatus() != Acad::eOk)
            return;

        CString sAppName = _T("TestExData");
        int iValue = 999;

        acdbRegApp(sAppName);       
        struct resbuf* pExDataRb = acutBuildList(1001,sAppName,AcDb::kDxfXdInteger16,iValue,0);
        spEnt->setXData(pExDataRb);
        acutRelRb(pExDataRb);
        acutPrintf(_T("n 写扩展数据成功"));
    }
删除名为sAppName的扩展数据
    struct resbuf* pExDataRb = acutBuildList(1001,sAppName,0);
    spEnt->setXData(pExDataRb);
删除所有的扩展数据
    resbuf* Append(IN OUT resbuf *&rb, resbuf *rb1)
    {
        resbuf*   pReturn = rb;
        resbuf*   rb_tep;
        if(rb == NULL) 
        {
            rb = rb1;
            return rb1;
        }
        else
        {
            for(rb_tep = rb; rb_tep->rbnext != NULL; rb_tep = rb_tep->rbnext);  

            rb_tep->rbnext = rb1;
        }
        return pReturn;
    }

    BOOL DelAlL(AcDbObject* pObj,CString sAppName)
    {
        resbuf *pResbuf, *pRbSet = NULL;
        CString sPattern = sAppName.IsEmpty()?_T("*"):sAppName;
        sPattern.MakeUpper();

        ArxDbgRbList spRb = pObj->xData();
        pResbuf = spRb.data();
        while(pResbuf != NULL)
        {
            resbuf *pTmp;
            if (pResbuf ->restype == 1001)
            {
                sAppName = pResbuf->resval.rstring;
                sAppName.MakeUpper();
                if (acutWcMatchEx(sAppName,sPattern,false) == RTNORM)
                {
                    pTmp = acutNewRb(1001);
                    acutNewString(pResbuf->resval.rstring,pTmp->resval.rstring);
                    Append(pRbSet,pTmp);
                }
            }
            pResbuf = pResbuf->rbnext;
        }
        if(pRbSet != NULL)
        {
            pObj->setXData(pRbSet) == Acad::eOk;
            acutRelRb(pRbSet);
        }
        return TRUE;
    }
Copyright (c) 2010. All rights reserved.
你认为该帮助怎么样? 发送反馈信息!