• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
梧桐爱凤
博客园    首页    新随笔    联系   管理    订阅  订阅

AutoCAD Plant3d 数据读取(类似Revit的Lookup) (一)

Plant3d Lookup

背景

在Plant3d的开发过程中,发现缺少一个类似revit的信息查看工具,同时做一些数据验证

思路

  • 启动拾取
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptEntityResult res = ed.GetEntity("\n选择一个实体: ");
  • 读取信息
            using (Transaction transaction = dwg.TransactionManager.StartTransaction())
            {
                DBObject ent = transaction.GetObject(res.ObjectId, OpenMode.ForRead);
                if (ent == null)
                {
                    return string.Empty;
                }
                if (res.ObjectId.ObjectClass.IsDerivedFrom(RXObject.GetClass(typeof(Pipe))))
                {
                    return Read(ent as Pipe);
                }
                else if (res.ObjectId.ObjectClass.IsDerivedFrom(RXObject.GetClass(typeof(Equipment))))
                {
                    return Read(ent as Equipment);
                }

                return "未识别对象";
            }

每多学一点知识,就少写一行代码
posted @ 2020-02-29 21:26  梧桐爱凤  阅读(696)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3