[ARX.NET]添加 XDATA数据

public static void AppendResultBuffer(ResultBuffer rb, ResultBuffer pHead)
        {
            foreach (TypedValue tv in pHead)
            {
                rb.Add(tv);
            }
        }

//添加 XDATA数据
        public static ErrorStatus WriteXData(Transaction trans, DBObject pEnt, string strName, ResultBuffer pHead)
        {
            ResultBuffer pHead1 = GetXdata(pEnt, strName);
            if (null == pHead1)
            {
                ErrorStatus es = RegisterApp(trans, pEnt.Database, strName);
                if (ErrorStatus.OK != es)
                {
                    return es;
                }
            }
            ResultBuffer pXdata = pEnt.XData;
            if (pXdata == null)
            {
                pEnt.XData = pHead;
                return ErrorStatus.OK;
            }
            ResultBuffer rb = new ResultBuffer();
            TypedValue[] tvs = pXdata.AsArray();
            for (int i = 0; i < tvs.Length; i++)
            {
                TypedValue tv = tvs[i];
                if (tv.TypeCode != (short)DxfCode.ExtendedDataRegAppName)
                {
                    rb.Add(tv);
                    continue;
                }
                if (string.Compare(tv.Value.ToString(), strName) != 0)
                {
                    rb.Add(tv);
                    continue;
                }
                AppendResultBuffer(rb, pHead);
                int nNext = -1;
                for (int j = i + 1; j < tvs.Length; j++)
                {
                    TypedValue tv1 = tvs[j];
                    if (tv1.TypeCode == (short)DxfCode.ExtendedDataRegAppName)
                    {
                        nNext = j;
                        break;
                    }
                }
                if (nNext > 0)
                {
                    for (int j = nNext; j < tvs.Length; j++)
                    {
                        rb.Add(tvs[j]);
                    }
                }
                pEnt.XData = rb;
                return ErrorStatus.OK;
            }
            AppendResultBuffer(rb, pHead);
            pEnt.XData = rb;
            return ErrorStatus.OK;
        }

此条目发表在ObjectArx.Net分类目录。将固定链接加入收藏夹。

发表评论