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 错误. 总结一下发生错误的原因,一般的 ...
随机推荐
- 113-PHP使用instanceof判断变量是否为某个类对象
<?php class ren{ //定义人类 } class mao{ //定义猫类 } $ren=new ren(); //实例化一个人类的对象 $mao=new mao(); //实例化一 ...
- Oracle SQL语句记录
1.oracel 查看表空间使用情况. ) AS free_space, tablespace_name FROM dba_free_space GROUP BY tablespace_name; ) ...
- ubuntu18.04 基于Hadoop3.1.2集群的Hbase2.0.6集群搭建
前置条件: 之前已经搭好了带有HDFS, MapReduce,Yarn 的 Hadoop 集群 链接: ubuntu18.04.2 hadoop3.1.2+zookeeper3.5.5高可用完全分布式 ...
- Vuex基本介绍
1.什么是Vuex Vuex是一个专为vue.js应用程序开发的状态管理模式. 状态管理:data里面的变量都是vue的状态. 2.为什么要用Vuex 当我们构建一个中大型的单页面应用程序时,Vuex ...
- java04异常处理课堂总结
一,动手动脑 1,请阅读并运行AboutException.java示例,然后通过后面的几页PPT了解Java中实现异常处理的基础知识. import javax.swing.*; class Abo ...
- jquery播放mp3
$("button").on("click",function(){ $('embed').remove(); $('body'). ...
- 16 ~ express ~ 添加博客分类
一,创建表结构 /schemas/categories.js var mongoose = require('mongoose') module.exports = new mongoose.S ...
- 第二阶段scrum-3
1.整个团队的任务量: 2.任务看板: 会议照片: 产品状态: 前端制作完成,数据库正在配置
- 路飞学城—Python爬虫实战密训班 第三章
路飞学城—Python爬虫实战密训班 第三章 一.scrapy-redis插件实现简单分布式爬虫 scrapy-redis插件用于将scrapy和redis结合实现简单分布式爬虫: - 定义调度器 - ...
- CSS绘制小三角
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...