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
    }
  • 相关阅读:
    http缓存机制与原理
    BFC与浮动
    05ICMP协议与ARP协议(IP协议中重要协议)
    04IP编址(网络层)
    03以太网帧结构(链路层 IEEE802.3)
    02传输介质简介
    shell 脚本 2
    shell 脚本 1
    shell 中时间 表达
    sed 行编辑器
  • 原文地址:https://www.cnblogs.com/JJBox/p/13811012.html
Copyright © 2011-2022 走看看