惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - 胡敏

WebSharp 3.0(个人修订版)全代码,WebSharp 的作者已经抛弃它了吗?(一个国产ORM框架) 从追MM谈Java的23种设计模式 - 太经典了,转到自己的BLOG上收藏着先 利用.net创建安全COM控件 我的家——三维地图 一个数独问题的算法(已更新,提供一个简单算法,欢迎拍砖) 生活在垃圾网络中,我们该怎么办? vs.net 2005 中文版下载 c#调用des64.dll进行加密解密 - 胡敏 - 博客园 MapXtreme 2004 6.2 中文版破解文件及安装方法(已经不提供下载) 提供MapXtreme 2004 6.2 NCP破解文件及安装方法(已经不能提供了,等待破解最新的吧) 爆笑经典签名 一句话经典笑话 MapXtreme2004新手资料续 MapXtreme2004初学者资料(整理) 移动用户查询手机开通的服务 使用 Rational XDE for .net建模和设计数据库(原创) 自己动手注册xde for .net帮助 如何得到别人收藏夹里的网址 十种你不知道的东西,绝对经典(如果你知道就不用点了,该休息了)(转)
AutoCAD二次开发之创建菜单
胡敏 · 2007-07-18 · via 博客园 - 胡敏

利用AutoCAD 2004 类型库创建菜单,AutoCAD菜单是加载的acad.mns。
AutoCADConnector.cs

using System;

using AutoCAD;

using System.Runtime.InteropServices;

namespace AddMenu

{

    public class AutoCADConnector : IDisposable

    {

        private AcadApplication _application;

        private bool _initialized;

        private bool _disposed;

        public AutoCADConnector()

        {

            try

            {

                // Upon creation, attempt to retrieve running instance

                _application = (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application.16");

            }

            catch

            {

                try

                {

                    // Create an instance and set flag to indicate this

                    _application = new AcadApplicationClass();

                    _initialized = true;

                }

                catch

                {

                    Console.Write("请安装AutoCAD");

                    throw;

                }

            }

        }

        // If the user doesn't call Dispose, the

        // garbage collector will upon destruction

        ~AutoCADConnector()

        {

            Dispose(false);

        }

        public AcadApplication Application

        {

            get

            {

                // Return our internal instance of AutoCAD

                return _application;

            }

        }

        // This is the user-callable version of Dispose.

        // It calls our internal version and removes the

        // object from the garbage collector's queue.

        public void Dispose()

        {

            Dispose(true);

            GC.SuppressFinalize(this);

        }

        // This version of Dispose gets called by our

        // destructor.

        protected virtual void Dispose(bool disposing)

        {

            // If we created our AutoCAD instance, call its

            // Quit method to avoid leaking memory.

            if (!this._disposed && _initialized)

                _application.Quit();

            _disposed = true;

        }

    }

}

 //程序代码。

using System;

using System.Collections.Generic;

using System.Text;

using AutoCAD;

namespace AddMenu

{

    class Program

    {

        static void Main(string[] args)

        {

            using (AutoCADConnector connector = new AutoCADConnector())

            {

                AcadApplication acadApp = connector.Application;

                AcadMenuGroup mnugrpRAA;

                mnugrpRAA = acadApp.MenuGroups.Item(0);

                // Menu

                AcadPopupMenu mnupop;

                try

                {

                    mnupop = mnugrpRAA.Menus.Item("文件(&F)");

                }

                catch

                {

                    mnupop = mnugrpRAA.Menus.Add("文件(&F)");

                }

                string strCmd;

                AcadPopupMenuItem mnupopItem;

                strCmd = "start SaveToServer;";// 这个就是你要执行的外部程序.

                mnupopItem = mnupop.AddMenuItem(7, "保存到服务器", strCmd);

                mnupopItem.TagString = "ID_SavetoServer";

                mnugrpRAA.Save(AcMenuFileType.acMenuFileSource);

            }

        }

    }

}