当前位置: 首页 > news >正文

输出CAD图中第一个图元类型——c#实现

复制改图元到一个新dwg中,启动代码可实现

如下图设置:

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace ClassLibrary4
{public class Class1{[CommandMethod("ListEntities")]public static void ListEntities(){// Get the current document and database, and start a transactionDocument acDoc = Application.DocumentManager.MdiActiveDocument;Database acCurDb = acDoc.Database;using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()){// 以只读方式打开块表记录   Open the Block table record for readBlockTable acBlkTbl;acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,OpenMode.ForRead) as BlockTable;// 以只读方式打开模型空间的块表记录    Open the Block table record Model space for readBlockTableRecord acBlkTblRec;acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],OpenMode.ForRead) as BlockTableRecord;int nCnt = 0;acDoc.Editor.WriteMessage("\nModel space objects: ");// Step through each object in Model space and// display the type of object foundforeach (ObjectId acObjId in acBlkTblRec){acDoc.Editor.WriteMessage("\n" + acObjId.ObjectClass.DxfName);nCnt = nCnt + 1;}// If no objects are found then display a messageif (nCnt == 0){acDoc.Editor.WriteMessage("\n No objects found");}// Dispose of the transaction}}}
}


http://www.mrgr.cn/news/23099.html

相关文章:

  • 2024腾讯互联网AI应用专场
  • 每日一练:缺失的第一个正数
  • python爬虫代理ip池搭建
  • 找不到ucrtbased.dll无法继续执行代码怎么办,总结5个方法
  • 【C++ Primer Plus习题】14.2
  • JAVA springboot面试题今日分享
  • C语言从头学57——学习头文件locale.h
  • llvm后端之函数栈帧的创建与销毁
  • C语言深入理解指针5
  • LeetCode之区间
  • Pygame中Sprite类实现多帧动画3-3
  • 宽哥之家小程序任务脚本
  • 关于使用 @iconify/vue2图标库组件的离线使用
  • 【大数据】如何读取多个Excel文件并计算列数据的最大求和值
  • 数据结构与算法-morris遍历
  • 三、TOGAF(概述)
  • Python中的接口艺术:从概念到实战
  • leetcode 101.对称二叉树
  • OpenCV-轮廓检测
  • 开放式耳机具备什么特点?2024排行前十的四款百元蓝牙耳机推荐