zoukankan      html  css  js  c++  java
  • cad.net 图元反应器,图元事件,要加在提交数据库之后哟

    直接看代码

    using Autodesk.AutoCAD.DatabaseServices;
    using Autodesk.AutoCAD.EditorInput;
    using Autodesk.AutoCAD.Runtime;
    using Acap = Autodesk.AutoCAD.ApplicationServices.Application;
    using Autodesk.AutoCAD.Geometry;
    using System;
    
    namespace JoinBox
    {
    #if NET48
        public class Command_Test_MTextModified
        {
            [CommandMethod("Test_MTextModified", CommandFlags.Modal | CommandFlags.UsePickSet | CommandFlags.DocExclusiveLock)]
            public void Test_MTextModified()
            {
                Database db = HostApplicationServices.WorkingDatabase;//当前的数据库   
                //using (Acap.DocumentManager.MdiActiveDocument.LockDocument())//锁文档
                {
                    using (Transaction tr = db.TransactionManager.StartTransaction())
                    {
                        for (int i = 0; i < 10; i++)
                        {
                            var acBlkTblRec = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
    
                            var mText = new MText
                            {
                                Contents = "文字" + i.ToString(),
                                TextHeight = 3,
                                TextStyleId = db.Textstyle,
                                Location = new Point3d(i, i, 0),
                            }; 
                            acBlkTblRec.AppendEntity(mText);
                            tr.AddNewlyCreatedDBObject(mText, true);
    
                            mText.Modified += MText_Modified; //要加在这里,如果加在提交之前,所有的事件将指向第一个图元..
                        }
                        tr.Commit();
                    }  
                }
            }
    
            private void MText_Modified(object sender, EventArgs e)
            {
                Editor ed = Acap.DocumentManager.MdiActiveDocument.Editor;
                ed.WriteMessage("
    测试" + ((MText)sender).Text);
            }
    
        }
    #endif
    }
  • 相关阅读:
    shell & awk 变量传递
    ubuntu下SVN服务器安装配置
    zabbix客户端配置
    python操作Excel读写--使用xlrd
    Zabbix Agent-Windows平台配置指导
    centos6.5下Zabbix系列之Zabbix安装搭建及汉化
    Centos 下安装Zabbix Linux 客户端
    zabbix监控mysql主从复制
    Zabbix利用msmtp+mutt发送邮件报警
    vue props传数组爬坑
  • 原文地址:https://www.cnblogs.com/JJBox/p/13811012.html
Copyright © 2011-2022 走看看