#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<string> layerNames = new List<string>();
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

How to get AutoCAD Mtext content的更多相关文章

  1. AutoCAD系统变量一览表

    p.MsoNormal,li.MsoNormal,div.MsoNormal { margin: 0cm; margin-bottom: .0001pt; text-align: justify; t ...

  2. AutoCAD .NET二次开发(三)

    在ArcGIS中,锁是一个经常遇到的东西,在打开一个该当时要锁定,编辑一个文档是再次锁定.要深入理解这个,要学习一下进程与线程.在CAD.NET中,也有Lock与Unlock. 获取一个文档,在进行处 ...

  3. AutoCAD 2009及以上 32位&64位 官方原版下载地址

    AutoCAD 2017 AutoCAD 2017 简体中文版 32位 http://trial2.autodesk.com/NET17SWDLD/2017/ACD/DLM/AutoCAD_2017_ ...

  4. AutoCAD 2019.0.1 Update 官方简体中文版

    欧特克三维机械设计软件AutoCAD 2019版本于2018年3月23号全球正式发布,新版本图标全新设计,视觉效果更清晰:在功能方面,全新的共享视图功能.DWG文件比较功能:现在打开及保存图形文件已经 ...

  5. 转:用AutoCAD 系统变量编程

    Autocad的系统变量, 我们可以通过如下得到: Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable(/*MSG0* ...

  6. AutoCad 二次开发 文字镜像

    AutoCad 二次开发 文字镜像 参考:https://adndevblog.typepad.com/autocad/2013/10/mirroring-a-dbtext-entity.html 在 ...

  7. requests的content与text导致lxml的解析问题

    title: requests的content与text导致lxml的解析问题 date: 2015-04-29 22:49:31 categories: 经验 tags: [Python,lxml, ...

  8. Content Security Policy 入门教程

    阮一峰文章:Content Security Policy 入门教程

  9. android 使用Tabhost 发生could not create tab content because could not find view with id 错误

    使用Tabhost的时候经常报:could not create tab content because could not find view with id 错误. 总结一下发生错误的原因,一般的 ...

随机推荐

  1. 开源DDD设计模式框架YMNNetCoreFrameWork第三篇-增加ASp.net core Identity身份认证,JWT身份认证

    1.框架增加Identity注册功能 2.框架增加identity登录以后获取JWTtoken 3.请求接口通过token请求,增加验证特性 源代码地址:https://github.com/topg ...

  2. (二)Spring初步搭建、IOC创建对象

    环境准备: 见java环境搭建 新建maven项目,同时搭好项目结构,新建相应的包 Spring的初步搭建 1.导入jar包,Spring版本为5.1.10,同时导入junit包 <depend ...

  3. 二十八、SAP中通过以字段以表格形式输出

    一.重点在与表格长度的计算,以及LINE-SIZE的用法,代码如下 二.输出效果如下

  4. 137-PHP static修饰的类属性

    <?php class test{ //定义一个类 public static $num=0; //定义static修饰的类属性 public function __construct(){ / ...

  5. UVALive 4287 SCC-Tarjan 加边变成强连通分量

    还是强连通分量的题目,但是这个题目不同的在于,问你最少要添加多少条有向边,使得整个图变成一个强连通分量 然后结论是,找到那些入度为0的点的数目 和 出度为0的点的数目,取其最大值即可,怎么证明嘛... ...

  6. 十四、 React路由(react-router4.x): 动态路由、get传值、React中使用url模块

    概述 新闻列表 -跳转-> 详情页 时,想把列表对应的id传到详情页里,可用到三种传值方法: 1.动态路由传值 2.get传值 3.localstorage传值 一.动态路由传值 [App.js ...

  7. Node.js NPM 作用

    章节 Node.js NPM 介绍 Node.js NPM 作用 Node.js NPM 包(Package) Node.js NPM 管理包 Node.js NPM Package.json NPM ...

  8. ACM-牛喝水

    题目描述:牛喝水  The cows have a line of 20 water bowls from which they drink. The bowls can be either righ ...

  9. 【Android】家庭记账本手机版开发报告七

    一.说在前面  昨天 实现了账单的图标显示  今天 本地化,测试APP,将工程源码放到github上 源码:https://github.com/xiaotian12-call/Android_Boo ...

  10. 19 01 16 jquery 的 属性操作 循环 jquery 事件 和事件的绑定 解绑

    jquery属性操作 1.html() 取出或设置html内容 // 取出html内容 var $htm = $('#div1').html(); // 设置html内容 $('#div1').htm ...