资源简介

查看扩展属性——sx,添加扩展属性——add;备注:截图中的信息纯属虚构

这是添加属性之前

添加自定义属性之后


资源截图

代码片段和文件信息

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace Cad_图元扩展属性读写
{
    public static  class Class1
    {
        //查看属性
        [CommandMethod(“sx“)]
        public static void Tst()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            PromptEntityOptions opt = new PromptEntityOptions(“\n 请选择实体:“);
            PromptEntityResult res = ed.GetEntity(opt);

            if (res.Status == PromptStatus.OK)
            {
                Transaction tran = doc.TransactionManager.StartTransaction();
                using (tran)
                {
                    DBobject obj = tran.Getobject(res.objectId OpenMode.ForRead);
                    ResultBuffer rb = obj.XData;
                    if (rb == null)
                    {
                        ed.WriteMessage(“\n 该图元没有实体属性!“);

                    }
                    else
                    {
                        StringBuilder Properties=new StringBuilder();//这里为了更好的展示用
                        foreach (TypedValue tv in rb)
                        {
                            switch (tv.TypeCode)
                            {
                                case 1001:
                                    ed.WriteMessage(“\n类型:{0};字段名称:{1}“
                                           tv.TypeCode//dxf组码
                                           tv.Value//值
                                           );
                                #region 存储属性
                                    string Property_Field = string.Format(“\n类型:{0};字段名称:{1}“
                                           tv.TypeCode//dxf组码
                                           tv.Value//值
                                           );
                                    Properties.AppendLine(Property_Field);
                                #endregion
                                    break;
                                case 1000:
                                    ed.WriteMessage(“\n类型:{0};字段内容:{1}“
                                           tv.TypeCode
                                           tv.Value
                                           );
                                    #region 存储属性
                                    string Property_Content = string.Format(“\n类型:{0};字段内容:{1}“
                                           tv.TypeCode//dxf组码
                                           tv.Value//值
                                           );
                                    Properties.AppendLine(Property_Content);
                                #endregion
                                    break;
              

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件    1975416  2005-03-05 20:13  Cad 图元扩展属性读写\Cad 图元扩展属性读写\bin\Debug\acdbmgd.dll

     文件      11896  2005-03-05 20:13  Cad 图元扩展属性读写\Cad 图元扩展属性读写\bin\Debug\AcDbMgdHost.dll

     文件    1070200  2005-03-05 20:16  Cad 图元扩展属性读写\Cad 图元扩展属性读写\bin\Debug\acmgd.dll

     文件       7680  2020-09-17 19:23  Cad 图元扩展属性读写\Cad 图元扩展属性读写\bin\Debug\Cad 图元扩展属性读写.dll

     文件      15872  2020-09-17 19:23  Cad 图元扩展属性读写\Cad 图元扩展属性读写\bin\Debug\Cad 图元扩展属性读写.pdb

     文件       2810  2020-09-17 19:21  Cad 图元扩展属性读写\Cad 图元扩展属性读写\Cad 图元扩展属性读写.csproj

     文件       6641  2020-09-17 19:23  Cad 图元扩展属性读写\Cad 图元扩展属性读写\Class1.cs

     文件       1136  2020-09-17 19:22  Cad 图元扩展属性读写\Cad 图元扩展属性读写\obj\Debug\Cad 图元扩展属性读写.csproj.FileListAbsolute.txt

     文件       7680  2020-09-17 19:23  Cad 图元扩展属性读写\Cad 图元扩展属性读写\obj\Debug\Cad 图元扩展属性读写.dll

     文件      15872  2020-09-17 19:23  Cad 图元扩展属性读写\Cad 图元扩展属性读写\obj\Debug\Cad 图元扩展属性读写.pdb

     文件       6873  2020-09-17 19:23  Cad 图元扩展属性读写\Cad 图元扩展属性读写\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件          0  2020-09-17 19:09  Cad 图元扩展属性读写\Cad 图元扩展属性读写\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2020-09-17 19:09  Cad 图元扩展属性读写\Cad 图元扩展属性读写\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2020-09-17 19:09  Cad 图元扩展属性读写\Cad 图元扩展属性读写\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件       1376  2020-09-17 19:09  Cad 图元扩展属性读写\Cad 图元扩展属性读写\Properties\AssemblyInfo.cs

     文件        974  2020-09-17 19:09  Cad 图元扩展属性读写\Cad 图元扩展属性读写.sln

    ..A..H.     39936  2020-09-17 19:21  Cad 图元扩展属性读写\Cad 图元扩展属性读写.v11.suo

     目录          0  2020-09-17 19:09  Cad 图元扩展属性读写\Cad 图元扩展属性读写\obj\Debug\TempPE

     目录          0  2020-09-17 19:22  Cad 图元扩展属性读写\Cad 图元扩展属性读写\bin\Debug

     目录          0  2020-09-17 19:09  Cad 图元扩展属性读写\Cad 图元扩展属性读写\bin\Release

     目录          0  2020-09-17 19:23  Cad 图元扩展属性读写\Cad 图元扩展属性读写\obj\Debug

     目录          0  2020-09-17 19:09  Cad 图元扩展属性读写\Cad 图元扩展属性读写\bin

     目录          0  2020-09-17 19:09  Cad 图元扩展属性读写\Cad 图元扩展属性读写\obj

     目录          0  2020-09-17 19:09  Cad 图元扩展属性读写\Cad 图元扩展属性读写\Properties

     目录          0  2020-09-17 19:09  Cad 图元扩展属性读写\Cad 图元扩展属性读写

     目录          0  2020-09-17 19:09  Cad 图元扩展属性读写

----------- ---------  ---------- -----  ----

              3164362                    26


评论

共有 条评论