明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1336|回复: 6

[事件] 如何在打开一个图形后新建图层

[复制链接]
发表于 2018-12-15 11:35 | 显示全部楼层 |阅读模式
请教下高手们,用c#做cad二次开发时,我想实现打开一个图件后,自动新建一个图层,有什么好法吗?
 楼主| 发表于 2018-12-16 10:23 | 显示全部楼层
建立事件与回调函数之间的连接应该这样写Application.DocumentManager.DocumentActivated += new DocumentCollectionEventHandler(AddLayer),但是不知道这句话放在dll中命名空间的那个位置才能在加载dll时自动运行这句话。自己顶下,高手们帮忙解决下啊!
发表于 2018-12-16 20:37 | 显示全部楼层
调用open()方法后,接着处理新建图层的方法
发表于 2019-1-13 20:34 | 显示全部楼层
在这个里面实现  IExtensionApplication.Initialize
发表于 2019-9-5 10:45 | 显示全部楼层
楼上正解
一般流程就是:
1、autocad运行是自动加载插件
2、插件自动运行文件打开监控事件
发表于 2021-5-17 12:51 | 显示全部楼层
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using System;


[assembly: ExtensionApplication(typeof(HfkxCAD.Initialization))]
namespace HfkxCAD
{
    public class Initialization : Autodesk.AutoCAD.Runtime.IExtensionApplication

    {
        WpfSystemSet wpf = new WpfSystemSet();
        public void Initialize()
        {
           
            Autodesk.AutoCAD.ApplicationServices.Application.ShowModalWindow(wpf);
        }

        public void Terminate()

        {
            //wpf.Close();
           //Console.WriteLine("Cleaning up...");

        }
    }
}

我首次加载DLL时会出现自定义的窗体,但采用OPEN和NEW时该窗体不显示,是什么原因
发表于 2021-5-17 12:53 | 显示全部楼层
我想。在运行CAD后出现窗体和打开、新建文档是出现窗体,不知采用什么方法;麻烦高手指教
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-4-18 23:31 , Processed in 0.218165 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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