zoukankan      html  css  js  c++  java
  • Autocad 2010+ObjectArx 2010 +Vs2010 的.net 开发设置(转)

     

    Autocad 2010+ObjectArx 2010 +Vs2010 的.net 开发设置

    分类: ObjectArx.net2010-09-14 16:52 4203人阅读 评论(7) 收藏 举报
     

    目录(?)[+]

     

    1.开发基本资料准备

    用Vs2010进行Autocad 2010开发,首先下载ObjectArx 2010 SDK。

    http://download.autodesk.com/akdlm/esd/dlm/objectarx/ObjectARX_2010_Win_64_and_32Bit.exe

    2.使用Visual Studio .NET来创建一个新的类库工程

    (1)建立类库项目

              启动Visual Studio.NET,选择”文件>新建>工程”(File> New> Project)。在新建工程对话框中选择工程类型为”Visual C#工程”,然后选择“windows”>”类库”模板,点击确定按钮来创建工程。

     

    (2)添加引用

            在项目引用中添加acdbmgd.dll和acmgd.dll,默认位置在c:/ObjectARX 2010/inc-win32下。

           添加引用后,展开引用,单击AcDbMgd和AcMgd,将其属性复制到本地分别改为False,否则可能会出现编译错误。

           AutoCAD 2010 采用 .Net Framework 3.5 版本,Vs 2010 创建默认工程采用.Net Framework 4.0 版本,必须将目标框架改为Net Framework 3.5 。修改方法:菜单 项目>ClassLibrary1属性>应用程序>框架属性,选择 .Net Framework 3.5 就可以了。

     

    (3) 导入命名空间。

    如:

     

    using Autodesk.AutoCAD.ApplicationServices;

    using Autodesk.AutoCAD.EditorInput;

    using Autodesk.AutoCAD.Runtime;

     

    (4)  加入自定义命令

    新建HelloWorld的自定义AutoCAD 命令,可以这么做:

    [c-sharp] view plaincopy
    1. using System;  
    2. using System.Collections.Generic;  
    3. using System.Linq;  
    4. using System.Text;  
    5. using Autodesk.AutoCAD.ApplicationServices;  
    6. using Autodesk.AutoCAD.EditorInput;  
    7. using Autodesk.AutoCAD.Runtime;  
    8. namespace ClassLibrary1  
    9. {  
    10.     public class Class1  
    11.     {  
    12.         [CommandMethod("HelloWorld")]  
    13.         public void HelloWorld()  
    14.         {  
    15.             Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;  
    16.             ed.WriteMessage("Hello World");  
    17.         }  
    18.     }  
    19. }  

      

    该命令在当前命令行显示 Hello World。

     

    3. 编译和调试

    (1)手动加载

    点击生成>生成解决方案,编译完成。

    要加载生成的DLL文件,必须用Netload命令。在AutoCAD命令行输入Netload,选择 ClassLibrary1.dll 就可以加载了。

    在命令行输入 HelloWorld 命令,就可以看到其执行效果了。

    Netload加载的程序不能卸载,要想再调试只能退出Autocad,然后重新编译、加载。

    (2)自动加载

           菜单 项目>ClassLibrary1属性>调试>启动操作,选择启动外部程序,程序名为AutoCAD.exe ,默认安装位置在c:/Program Files/AutoCAD 2010/acad.exe;命令行参数设置  /nologo /b "d:/ClassLibrary1/ClassLibrary1/bin/debug/start.scr" 。

           start.scr 文件是自己编写的autocad运行脚本文件,该文件是文本文件,添加一行文本:netload "d:/ClassLibrary1/ClassLibrary1/bin/debug/ ClassLibrary1.dll" 

    这样我们就可以直接运行调试了。

    (3)调试

    按照以上步骤运行后,不支持断点调试,我们还应修改acad.exe.config.xml文件,该文件在c:/Program Files/AutoCAD 2010/下,增加一行 <supportedRuntime version="v2.0.50727"/>内容。修改后的acad.exe.config.xml的内容如下:

    <configuration>

       <startup>

    <supportedRuntime version="v2.0.50727"/>

       </startup>

    <!--All assemblies in AutoCAD are fully trusted so there's no point generating publisher evidence-->

       <runtime>        

    <generatePublisherEvidence enabled="false"/>    

       </runtime>

    </configuration>

  • 相关阅读:
    Git简介
    git 目录
    版本控制系统介绍
    python 爬虫 基于requests模块发起ajax的post请求
    python 爬虫 基于requests模块发起ajax的get请求
    POJ 2575
    POJ 2578
    POJ 2562
    POJ 2572
    POJ 2560
  • 原文地址:https://www.cnblogs.com/houlinbo/p/3325898.html
Copyright © 2011-2022 走看看