博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
How to get AutoCAD Mtext content
阅读量:4596 次
发布时间:2019-06-09

本文共 3142 字,大约阅读时间需要 10 分钟。

#region 提取一个图层上的各类元素        [CommandMethod("BlockInLayerCAD")]        public void BlockInLayerCAD()        {            Document ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;            Database db = HostApplicationServices.WorkingDatabase;            //PromptStringOptions pStringOption = new PromptStringOptions("\n 输入一个图层名");            //PromptResult layerName = pDocument.Editor.GetString(pStringOption);            List
layerNames = new List
(); using (Transaction tran = db.TransactionManager.StartTransaction()) { #region 获取图层名字 LayerTable pLayerTable = tran.GetObject(db.LayerTableId, OpenMode.ForRead) as LayerTable; foreach (ObjectId pObjectId in pLayerTable) { LayerTableRecord pLayerTableRecord = tran.GetObject(pObjectId, OpenMode.ForRead) as LayerTableRecord; layerNames.Add(pLayerTableRecord.Name); } #endregion string layerName = layerNames[0]; string typeResult ="文字"; TypedValue[] pTypedValue = new TypedValue[] { new TypedValue((int)DxfCode.LayerName, layerName) }; SelectionFilter pSelectFilter = new SelectionFilter(pTypedValue); PromptSelectionResult pSelectionResult = ed.Editor.SelectAll(pSelectFilter); SelectionSet pSelectionSet = pSelectionResult.Value; Point3d startPoint = new Point3d(); Point3d endPoint = new Point3d(); if (typeResult != "全部") { PromptPointOptions txtPoint = new PromptPointOptions("\n 选择两个点作为文字取值范围"); txtPoint.Message = "\n 选择第一个点:"; PromptPointResult txtStartPoint = ed.Editor.GetPoint(txtPoint); startPoint = txtStartPoint.Value; txtPoint.Message = "\n 选择第二个点:"; PromptPointResult txtEndPoint = ed.Editor.GetPoint(txtPoint); endPoint = txtEndPoint.Value; } foreach (ObjectId selectedId in pSelectionSet.GetObjectIds()) { Entity pEntity = tran.GetObject(selectedId, OpenMode.ForRead) as Entity; switch (typeResult) { case "文字": if ((pEntity as MText) != null) { MText mText = pEntity as MText; if (mText.Location.X > startPoint.X && mText.Location.Y < startPoint.Y && mText.Location.X < endPoint.X && mText.Location.Y > endPoint.Y) { Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog((pEntity as MText).Text); } } break; } } tran.Commit(); } }#endregion

 

转载于:https://www.cnblogs.com/fanxingthink/p/4176164.html

你可能感兴趣的文章
数字图像处理实验(5):PROJECT 04-01 [Multiple Uses],Two-Dimensional Fast Fourier Transform ...
查看>>
sqlite3:深入理解sqlite3_stmt 机制
查看>>
一个注释版的查取列表信息
查看>>
使用Ctex总结1
查看>>
ios关闭自动更新
查看>>
10 款非常棒的CSS代码格式化工具推荐
查看>>
【BZOJ2298】[HAOI2011]problem a
查看>>
【转】关于Jmeter3.0,你必须要知道的5点变化
查看>>
OJ使用心得
查看>>
day6_time模块和datetime模块
查看>>
AppUi自动化框架tool.py代码
查看>>
Oracle物理文件分类:
查看>>
请别随意关闭默认共享
查看>>
Linux CentOS中防火墙的关闭及开启端口
查看>>
机器学习中的数学(1)-回归(regression)、梯度下降(gradient descent)
查看>>
网页性能优化
查看>>
destoon网站转移空间教程
查看>>
.Net 三款工作流引擎比较:WWF、netBPM 和 ccflow
查看>>
P1280 尼克的任务(DP)
查看>>
在PC上测试移动端网站和模拟手机浏览器的5大方法
查看>>