明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1072|回复: 0

获取多重引线样式WDAGAIN 的属性,输出到命令行

[复制链接]
发表于 2016-7-7 15:17 | 显示全部楼层 |阅读模式
大侠看看这个程序这么改,获取多重引线样式WDAGAIN 的属性,输出到命令行
using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;


[assembly: CommandClass(typeof(GetMleaderStyle.GetMlStyle))]

namespace GetMleaderStyle
{
    public class GetMlStyle
    {
        [CommandMethod("GMlS")]
        public static void  GetMlSty()
        {
            Database db = Application.DocumentManager.MdiActiveDocument.Database;
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            using (Transaction acTrans = db.TransactionManager.StartTransaction())            
            {
                //获取所有多重标注样式
                DBDictionary MlStyleList = acTrans.GetObject(db.MLeaderStyleDictionaryId, OpenMode.ForRead) as DBDictionary;
                MLeaderStyle myMleaderStyle = new MLeaderStyle();
               //判断当前文件是否存在多重标注样式WDAGAIN,如果不存,执行下边语句。
                if (MlStyleList.Contains("WDAGAIN"))
               {  
                myMleaderStyle = acTrans.GetObject(MlStyleList["WDAGAIN"], OpenMode.ForRead) as MLeaderStyle;

                    //获取多重标注样式WDAGAIN的ArrowSymbolId属性。
                ObjectId MyArrowSymbol = myMleaderStyle.ArrowSymbolId;
                double MyTextHeight = myMleaderStyle.TextHeight;

                    // 调用Editor对象的WriteMessage函数在命令行上显示文本
                ed.WriteMessage( MyArrowSymbol );
                ed.WriteMessage( MyTextHeight );
                }
               acTrans.Commit();//回收内存   
            }      
        }      
    }
}

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-27 00:21 , Processed in 0.670354 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表