[ARX.NET]获取对象指定注册名的XData

/// <summary>
        /// 获取对象指定注册名的XData
        /// </summary>
        /// <param name=”obj”>对象</param>
        /// <param name=”regApptableName”>注册名</param>
        /// <returns></returns>
        public static ResultBuffer GetXdata(DBObject obj, string regApptableName)
        {
            ResultBuffer pXdata = obj.XData;
            if (pXdata == null)
            {
                return null;
            }
            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)
                    continue;
                if (string.Compare(tv.Value.ToString(), regApptableName) != 0)
                    continue;
                rb.Add(tv);
                for (int j = i + 1; j < tvs.Length; j++)
                {
                    TypedValue tv1 = tvs[j];
                    if (tv1.TypeCode == (short)DxfCode.ExtendedDataRegAppName)
                    {
                        return rb;
                    }
                    rb.Add(tv1);
                    if (j == tvs.Length – 1)
                    {
                        return rb;
                    }
                }
            }
            return null;
        }

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

发表评论