How to get AutoCAD Mtext content
#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的更多相关文章
- AutoCAD系统变量一览表
p.MsoNormal,li.MsoNormal,div.MsoNormal { margin: 0cm; margin-bottom: .0001pt; text-align: justify; t ...
- AutoCAD .NET二次开发(三)
在ArcGIS中,锁是一个经常遇到的东西,在打开一个该当时要锁定,编辑一个文档是再次锁定.要深入理解这个,要学习一下进程与线程.在CAD.NET中,也有Lock与Unlock. 获取一个文档,在进行处 ...
- AutoCAD 2009及以上 32位&64位 官方原版下载地址
AutoCAD 2017 AutoCAD 2017 简体中文版 32位 http://trial2.autodesk.com/NET17SWDLD/2017/ACD/DLM/AutoCAD_2017_ ...
- AutoCAD 2019.0.1 Update 官方简体中文版
欧特克三维机械设计软件AutoCAD 2019版本于2018年3月23号全球正式发布,新版本图标全新设计,视觉效果更清晰:在功能方面,全新的共享视图功能.DWG文件比较功能:现在打开及保存图形文件已经 ...
- 转:用AutoCAD 系统变量编程
Autocad的系统变量, 我们可以通过如下得到: Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable(/*MSG0* ...
- AutoCad 二次开发 文字镜像
AutoCad 二次开发 文字镜像 参考:https://adndevblog.typepad.com/autocad/2013/10/mirroring-a-dbtext-entity.html 在 ...
- requests的content与text导致lxml的解析问题
title: requests的content与text导致lxml的解析问题 date: 2015-04-29 22:49:31 categories: 经验 tags: [Python,lxml, ...
- Content Security Policy 入门教程
阮一峰文章:Content Security Policy 入门教程
- 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 错误. 总结一下发生错误的原因,一般的 ...
随机推荐
- 浅谈arduino的bootloader
在arduino的板子上,作为核心的avr单片机往往都会烧录一个bootloader,这个叫做bootloader的东东其实是arduino研发团队针对arduino板子开发的一小段代码,借助于这段代 ...
- Oracle SQL存储过程结构、异常处理示例
-- 存储过程结结构. -- EXCeption不是存储过程必须部分,可以用作本存储过程的异常处理,但如果没有异常处理,出了异常将会终止程序 CREATE PROCEDURE procedure_na ...
- spark-submit脚本分析
执行任务 ./spark-submit \ --class cn.com.dtmobile.spark.DebugTest \ --master yarn \ --deploy-mode client ...
- AI 人工智能产业园路口-----dp
北京市商汤科技开发有限公司建立了新的 AI 人工智能产业园,这个产业园区里有 nn 个路口,由 n - 1n−1 条道路连通.第 ii 条道路连接路口 u_iui 和 v_ivi. 每个路口都布有 ...
- Day 15:缓冲输入输出常用方法和小练习
以拷贝图片为例子,演示异常处理的代码: 拷贝一张图片 import java.io.File;import java.io.FileInputStream;import java.io.FileOut ...
- 通过while循环一步步实现九九乘法表
# 打印#做出@列的效果height = int(input("height: ")) #用户输入一个高度 num_height = heightwhile num_height ...
- s5pc100开发板linux内核移植
相关软件下载地址:http://pan.baidu.com/s/16yo8Y 应用于FSC100开发板 交叉编译工具:arm-cortex_a8-linux-gnueabi-gcc linux-2.6 ...
- Intent 显示意图 隐式意图
//显式意图 :必须指定要激活的组件的完整包名和类名 (应用程序之间耦合在一起) // 一般激活自己应用的组件的时候 采用显示意图 //隐式意图: 只需要指定要动作和数据就可以 ( 好处应用程序之 ...
- cmake的find_package()简单总结
遇到的问题 find_package(lzb)出现错误如下: CMake Warning at CMakeLists.txt:37 (find_package): By not providing & ...
- Vulkan SDK 之 Depth Buffer
深度缓冲是可选的,比如渲染一个3D的立方体的时候,就需要用到深度缓冲.Swapchain就算有多个images,此时深度缓冲区也只需要一个.vkCreateSwapchainKHR 会创建所有需要的i ...