#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. Arduino - 看门狗定时器(WDT:Watch Dog Timer)

    看门狗定时器(WDT:Watch Dog Timer)实际上是一个计数器. 一般给看门狗一个大数,程序开始运行后看门狗开始倒计数. 如果程序运行正常,过一段时间CPU应该发出指令让看门狗复位,令其重新 ...

  2. 微信公众号开发之根据OpenID列表群发(十四)

    上一篇我们讲述了<微信公众号开发之根据标签进行群发(十二)>,这次我们讲解一下[根据OpenID列表群发] 根据OpenID列表群发[订阅号不可用,服务号认证后可用] 接口调用请求说明 h ...

  3. 调试ASP.NET程序

    用VS打开你的项目 从VS中找到"调试"-----"附件到进程",然后选中w3wp.exe,点击附件到进程,然后再发送数据进行调试就可以了

  4. C++ do while无限循环~

    #include<iostream> using namespace std; #include<Windows.h> int main() { ; ; system(&quo ...

  5. 吴裕雄--天生自然C++语言学习笔记:C++ 数字

    下面是一个 C++ 中定义各种类型数字的综合实例: #include <iostream> using namespace std; int main () { // 数字定义 short ...

  6. 第一部分 JavaScript语言核心(四)

    第九章 类和模块 P235 组合VS子类:组合优于继承 P236 类的层次结构和抽象类 第十章 正则达式的模式匹配 定义 JS中正则表达式用RegExp对象表示.直接量定义为包含在一堆斜杠(/)之间的 ...

  7. MFC OCX 控件事件的添加和处理

    1.控件的事件一般都是由对外的接口引发到,这里定一个接口先: 该接口有一个字符串参数,表示调用者将传入一个字符串,传进来后,我们将取得字符串的长度. 2.添加事件: 事件应该是属于窗口的,所以在Ctr ...

  8. LARGE_INTEGER 64位的输出格式

    %016I64x 第一个016是指当最左边无数据时用00填充:后面的I64x是__int64的前缀要求格式十六进制输出.

  9. js interval ,timeout

    var inter; intervatest("2019-08-22 09:12:00"); function intervatest(str) { ShowCountDown(s ...

  10. poj 3693 Maximum repetition substring

    呵呵呵呵呵呵呵呵呵呵,sb(神犇)题看了一天,还是不懂 题目要求的是最多重复的,那么就来找重复的,可以先枚举一个重复的单元(比如ababab,就枚举ab)的长度, 然后再原串中,会有ch[0],ch[ ...