AutoCAD two times Development--autocad.net API Development Environment Construction

Source: Internet
Author: User
Tags autoloader sql 2014 visual studio 2010

AutoCAD two times Development--autocad.net API Development Environment Construction

AutoCAD two times Development--autocad.net API Development Environment Construction

AutoCAD Two-time development tool: 1986 autolisp,1989 ads,1990 year dcl,1993 ads-rx,1995 year objectarx,1996 year active X Automation (COM), 1997 VBA, 1998 Visual lisp,2006. NET API (DLL).

Trend and direction: Autocad.net API (AutoCAD2006 appears, form is called DLL plugin with netload)

ACAD, ARX, VS,. The NETFramework version corresponds to the relationship.

AutoCAD VS. NETFramework

2015 2012 4.5

2012-2014 2010/2012 4.0 also useful VS10 development runs in 08cad. net4.0 with DLR

2010-2011 3.5 cad10-12 User 28% The second recommendation is also useful vs08 run in cad08. After net3.0 there are LINQ,WPF,WF,WCF

There is no WPF,LINQ,WCF,WF below, so it is not recommended.

2007-2009 2005 2 CAD users 37% up to 64 bits of 07 and 15, this version is compatible with the most, this is the minimum required version. VC from VS2005 only Vc8

2004-2006 2002 Users 27% 06 years before the issue. Netapi, so it can't be used below 06

Since Arx and AutoCAD are all produced by Autodesk, the version number is the same.

The key to choosing a version counterpart is that the DLL referenced by the VS must be consistent with the target environment, AutoCAD. Next is the framework version. The above is just the best combination, but not a hard requirement.

CAD official:

Vs
CAD ARX Wiz
Cad.net Wiz

08
12

10
12/13
10-12/13

12
14/15/16
14/15/16

13
16

Office
VS2010 Office 07 10
VS2012 Office 10 13
VS2015 Office 10 13 16
Comprehensive:
VS2010 CAD12/13 Office 07/10
vs2012 CAD 14/15/16 Office 10/13
Preferred: Vs10 (c#,c++,vsto) CAD13 Office 10
VS2015 (C #) Office 10

Minimum standard: vs2010 framework3.5 cad2007 arx2007 SQL 2008R2

Classic environment: Win7 vs2010 CAD2013/2 arx2013

Fashion environment: Win10 vs2012 cad2016
Latest Version: Framework cad2016 SQL 2014

Considering that CAD two development is for the majority of users, and must be based on a certain CAD version and framework version, in order to ensure that the development of software can be used in most platforms, and the development environment is more humane, and has most features, the use of classic environment development. If you are using an individual or a designated environment, it is recommended that you use a stylish environment that runs under a common platform such as WIN10 and can also be added to the store.

Steps to build the environment:

1, install the Objectarx SDK (arx_all_2007) (there are two Lib interop, because the default location of the CAD is not good to find. )

2, install Autocad_2010-2012_dotnet_wizards (Development Wizard, eliminate the trouble of manual operation)

There are two ways to do this: ① manually set up class files Dll,② automatically with the Dotnet Wizard Wizards. Recommended wizards are quick and easy

Method One: Manually set up the class library

1, vs in the new class library.

2. Add References:

D:\Program Files (x86) \autocad 2007\ (by contrast with Objectarx 2007 inside, so with the CAD catalog)

AcCui.dll AcDbMgd.dll AcMgd.dll Completed: Accui acdbmgd ACMGD

D:\Program Files (x86) \autocad2007\objectarx 2007\inc

Acax17enu.tlb axdb17enu.tlb

Display after completion: AutoCAD, Axdblib

(Note: AutoCAD 2014 splits a AcCoreMgd.dll that is referenced when working with editors, publishing and printing, defining AUTOLISP commands, and functions.) )

3. Change local copy to False for referenced file attributes

4. Right-click on the project file-application-Target framework. NETFramework3.5 Output Type: Class Library,

Build ———— target platform: any CPU

Debug ———— Start external program: D:\Program Files (x86) \autocad 2007\acad.exe

5, add using, write code.

The using content is as follows **************//

Visula Studio2010//

//*******************************************//

Using System;

Using System.Collections.Generic;

Using System.Text;

//*******************************************//

Type Library//

//*******************************************//

Using Autodesk.AutoCAD.Interop; AutoCAD TypeLibrary

Using Autodesk.AutoCAD.Interop.Common; Autocad/objectdbxcommon 17.0 Type Library

Using Autodesk.AutoCAD.Customization; Accui.dll

//*******************************************//

Acdbmgd.dll//

//*******************************************//

Using Autodesk.AutoCAD.Runtime;

Using Autodesk.AutoCAD.LayerManager;

Using Autodesk.AutoCAD.GraphicsSystem;

Using Autodesk.AutoCAD.GraphicsInterface;

Using Autodesk.AutoCAD.Geometry;

Using Autodesk.AutoCAD.DatabaseServices.Filters;

Using Autodesk.AutoCAD.DatabaseServices;

Using Autodesk.AutoCAD.Colors;

//******************************************//

//--------------------------------------------//

Acmgd.dll//

//------------------------------------------*//

Using Autodesk.AutoCAD.Windows.ToolPalette;

Using Autodesk.AutoCAD.Windows;

Using Autodesk.AutoCAD.Publishing;

Using Autodesk.AutoCAD.PlottingServices;

Using Autodesk.AutoCAD.EditorInput;

Using Autodesk.AutoCAD.ApplicationServices;

Method Two: Directly established with wizards, can automatically reference the specified DLL, set the debug CAD path, can also write two CS file, a command, a start-off.

1, install Autocad_2010-2012_dotnet_wizards.

2, run vs2010--new c#--autodesk-autocadplug-in, select the. NET Framework 3.5

3, Objectarx Path: D:\ProgramFiles (x86) \autocad 2007

CAD path: D:\Program Files (x86) \autocad 2007

Select Interop Common, Interop, Accui

Displayed after completion: Accui ACDBMGD ACMGD

Interop Interop.common (should interact with the other two development modes, like VBA, LISP, ARX, as with Acax17enu.tlb,axdb17enu.tlb)

Autodesk.autocad.interop:c:\windows\assembly\gac_msil\autodesk.autocad.interop\17.0.54.0__eed84259d7cbf30b\ Autodesk.AutoCAD.Interop.dll

autodesk.autocad.interop.common:c:\windows\assembly\gac_msil\autodesk.autocad.interop.common\17.0.54.0__ Eed84259d7cbf30b\autodesk.autocad.interop.common.dll

4, Debug path, reference Copy Local false,framework3.5, x86,64 Select any CPU has been set by default, using the necessary also written, do not need to operate.

5, the default two classes, a MyCommands.cs MyPlugin.cs

MyCommands.cs: for Command mode

MyPlugin.cs: Execute when software is on or off

HelloWorld Operation code:

[Commandmethod ("Hello")]

public static void Hello ()

{

Editor Ed =application.documentmanager.mdiactivedocument.editor;

Ed. Writemessage ("Hello World");

}

The following is the HelloWorld sample code:

Using System;

Using Autodesk.AutoCAD.Runtime;

Using Autodesk.AutoCAD.ApplicationServices;

Using Autodesk.AutoCAD.DatabaseServices;

Using Autodesk.AutoCAD.Geometry;

Using Autodesk.AutoCAD.EditorInput;

To speed up loading, load the program directly by registering the commands in the class, otherwise search each class for commands.

[Assembly:commandclass (typeof (Wizarddotnetapi.mycommands))]

Namespace Wizarddotnetapi

{

public class Mycommands

{

[Commandmethod ("Hello", commandflags.session)]

public void Hello ()

{

Write our plug-in function here ***//

Editor Ed =application.documentmanager.mdiactivedocument.editor;

Ed. Writemessage ("HelloWorld");

Here we write the function will be used in each namespace class, interface, method, which is the focus of learning//

}

}

}

To run the code automatically:

Using System;

Using Autodesk.AutoCAD.Runtime;

Using Autodesk.AutoCAD.ApplicationServices;

Using Autodesk.AutoCAD.DatabaseServices;

Using Autodesk.AutoCAD.Geometry;

Using Autodesk.AutoCAD.EditorInput;

[Assembly:extensionapplication (typeof (Wizarddotnetapi.myplugin))]

Namespace Wizarddotnetapi

{

Publicclass myplugin:iextensionapplication

{

Voidiextensionapplication.initialize ()

{

Initialize your plug-in application here

}

Voidiextensionapplication.terminate ()

{

Do plug-in application

}

}

}

Part Two: Compiling and debugging

(1) Manual loading

Click Build > Build Solution, or debug-start debugging.

Start autocad--netload--Select class file under D:\Documents\VisualStudio 2010\projects\firstcaddll\firstcaddll. dll

Netload loaded programs can not be uninstalled, you want to debug can only exit AutoCAD, and then recompile, load.

(2) Automatic loading

Menu items > Properties > Debugging > Start Action, select Start external Program, AutoCAD.exe.

command-line parameter settings:/nologo/b "D:\Documents\Visual Studio 2010\projects\ One of My wizard-generated programs Dotnet_wizards_helloworld\dotnet_wizards_ HELLOWORLD\DOTNET_WIZARDS_HELLOWORLD\BIN\DEBUG\START.SCR "

The Start.scr file is the AutoCAD run script file that you wrote, which is a text file that adds a line of text: Netload "D:\Documents\Visual studio2010\projects\firstcaddll\ Firstcaddll\bin\debug\firstcaddll.dll "

So we can run the debug directly.

(3) Commissioning

After running on the above steps, breakpoint debugging is not supported, and we should also modify the Acad.exe.config. D:\Program files (x86) \autocad 2007 to add a line <supportedruntime version= "v2.0.50727"/> content. The contents of the modified Acad.exe.config.xml are as follows:

<configuration>

<startup>

<supportedruntime version= "v2.0.50727"/>

</startup>

<!--all assemblies in AutoCAD is fully trusted so there ' s Nopoint generating publisher evidence-->

<runtime>

<generatepublisherevidence enabled= "false"/>

</runtime>

</configuration>

Tip: Do not turn off CAD debugging.

Netload Loading program can not uninstall, to be able to debug can only exit AutoCAD, each compilation need to restart AutoCAD, very troublesome, to the web search all over, but no solution, all said that Microsoft did not develop this function, (it seems that I am too gentleman research Solutions, O (∩_∩) o~). After I've been trying to find a way to almost match the edit and continue, here are the alternatives:

1, according to the above steps to debug, any write a command such as Hello, set a breakpoint in this command, and then call this command in AutoCAD Runtime, will enter the VS Debug page, here can be modified. Use this Hello command every time you need to modify it.

Part III: Program Deployment

Before AutoCAD2012, use the registry to deploy, and then use the plug-in autoloader.

① Registry deployment: in the registry to start the loader, you can use a reg file, you can also write in the program (to refer to microsoft.win32), such as 2010 of the location of

[Hkey_local_machine\software\autodesk\autocad\r18.0\acad-8001:804\applications\xxx]

Description (description), Loadctrls (Load control load mode), loader (program path), managed (program form OX01 managed program)

Loadctrls:0x02:cad load at startup, 0x04 command load, 0x10 from not loaded, 0x20: Explicit load

(cad2007_64 bit in the registry does not have a fixed position, like interop as hard to find, with F3 search, the results are still not found, so the following code is not tested successfully. )

The contents of the Reg file are as follows:

[Hkey_local_machine/software/autodesk/autocad/r17.0/acad-5001:804/applications/yds]

"DESCRIPTION" = "Load Custom DLL file"

"Loadctrls" =dword:0000000c

"MANAGED" =dword:00000001

"LOADER" = "D:\\documents\\testdll\\hello.dll"

[Hkey_local_machine/software/autodesk/autocad/r17.0/acad-5001:804/applications/yds/commands]

"Showpalette" = "Showpalette"

5001 means that Autocad2007;loadctrls represents the way the load is described, and a value of 12 means that the DLL is loaded only when the command is issued, which is loaded when it is 2 o'clock (although I change to 2, it is not automatically loaded at startup); The value of managed is only 1. Indicates that it is a managed program.

Merging this registry, the next time you start autocad2007, you can automatically load the associated DLL, and execute which command.

②: Configuration file Deployment: plug-in autoloader, Applicationplugins package Xxx.bundle (contains contents\ DLL and Packagecontents.xml), when CAD starts, the data in the Packagecontents.xml is automatically loaded.

CAD Catalog Location: C:\ProgramFiles\Autodesk\ApplicationPlugins

XP My document location: C:\Documentsand settings\administor\application data\autodesk\applicationplugins

Win7 My document location: C:\Users\Administrator\AppData\Roaming\Autodesk\ApplicationPlugins

③ calls the "netload" command in Lisp language to load the DLL automatically.

The contents of the ①lsp file are as follows:

(COMMAND "Netload" "D:\\documents\\testdll\\hello.dll")

(Command "Hello")

The first sentence indicates that AutoCAD loads the specified DLL with \ \ To escape, avoiding special symbols such as \ t.

The second sentence indicates that a command named "Hello" is executed. In this case, the DLL has the Hello command, and it executes immediately.

Start autocad2007, tools->autocadlisp-> load application in the popup form of the launch group to add the above LSP file path.

② can also define a command call that does not start directly.

(Defun C:hello ()

(COMMAND "Netload" "D:\\documents\\testdll\\hello.dll")

(Command "Hello")

(Princ)

)

The above hello is the definition of the function name, the following is the DLL inside the command, the first time to do hello, execute the above LSP content, while there is a hello is a DLL command, the second execution directly executes the DLL command.

③ another call LSP Method (Failed test, no reason found): Found D:\Program Files (x86) \autocad 2007\SUPPORT\ACAD2007.LSP in the AutoCAD installation directory

Open it with Notepad and add it at the end (the second line of code, note the path)

(Command "Netload" "D:\Documents\testdll\hello.dll")

The complete code is:

(arxload "Vel.arx")

(if (Not (substr (ver) 1 one) "Visual LISP")) (Load "ACAD2007DOC.LSP"))

(Command "Netload" "D:\Documents\testdll\hello.dll")

;; Silent load.

(Princ)

2. AutoCAD settings (important, must be set): Tools-Options-Files-Support file search path-add-Browse to Hello.dll path

④, with . NET Program Loading . NET Assembly , using the System.Reflection command space in Microsoft's core class library mscorlib. As long as a function assembly.loadfrom () can be loaded, it is fast. This method can be loaded in the background at any time. NET assembly, but the managed assembly cannot be unloaded until the AutoCAD is closed. The method originates from Kean (C #) and is not tested:

From: http://www.lubanren.net/weblog/post/209.html

UsingAutodesk.AutoCAD.ApplicationServices;

UsingAutodesk.AutoCAD.EditorInput;

UsingAutodesk.AutoCAD.Runtime;

Usingsystem.reflection;

Namespaceloadmodule

{

public class Commands

{

[Commandmethod ("MNL")]

static public void Mynetload ()

{

Document doc =

Application.DocumentManager.MdiActiveDocument;

Editor ed = doc. Editor;

Promptstringoptions PSO =

New Promptstringoptions (

"\ n Enter the full path of the assembly to be loaded:"

);

Pso. Allowspaces = true;

Promptresult PR =ed. GetString (PSO);

if (pr. Status! = Promptstatus.ok)

Return

Try

{

Assembly.LoadFrom (pr. Stringresult);

}

catch (System.Exception ex)

{

Ed. Writemessage (

"\ nthe assembly {0}: {1}" could not be loaded,

pr. Stringresult,

Ex. Message

);

}

}

}

}

Recommendation: The algorithm is the core, what language, environment, deployment, are the appearance, the key is to learn thinking and algorithms.

Resources:

Objectarx. NET Forum: http://www.objectarx.net/forum.php?mod=forumdisplay&fid=6

English manual:

Http://www.mjtd.com/helpcenter/netguide/index.html?url=WS73099cc142f48755-5c83e7b1120018de8c0-23fe.htm,topicNumber=d0e79

Official address: http://usa.autodesk.com/adsk/servlet/index?id=1911627&siteID=123112

Official Tutorial 2015 Development Wizard: HTTP://HELP.AUTODESK.COM/VIEW/ACD/2015/ENU/?GUID=GUID-C3F3C736-40CF-44A0-9210-55F6A939B6F2

Ming Jing Channel: http://www.mjtd.com/caddevelop/info-61-1094.html

Luban people [Ben ' sblog] Civil Engineering Knowledge: http://www.lubanren.net/weblog/catalog.asp?cate=6&page=2
Ming Jing Channel http://www.mjtd.com/
Hiu Tung CAD http://bbs.xdcad.cn/
Version issue:
http://blog.csdn.net/zx_pisan/article/details/6311472
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=100420;

Books: As of 2015.1.19, search all over the network, the English material is many, but understanding difficult, Chinese in the following four books best conforms to the. NET API learning, the rest have seen, no. As long as you learn the following four books is enough!
C # autocad.net API

1. AutoCAD VBA &vb. NET development Fundamentals and Example Tutorials (2nd edition) (C # Edition) 2013-6 88.00 USD china Power Press Zenghongfei, Lu Ling, Zhang Fan pages 621 AutoCAD 2012Visual Studio

2. [Autocad.net two times development]. Li Guanxi china Industry Press 2012.2 Pricing 78 with CD-ROM P485 with. NET, combined with a variety of two development methods.

3. Development of AutoCAD based on Visual C # and its application in engineering Xiaozeiun Three Gorges University 2010.4 P218 online version of the ActiveX, but the content of civil engineering CAD two development, the main learning algorithm ideas.

4. Web version of AutoCAD. NET Development Guide 2012, P629 Sun Chengpo 2014.2.8 AutoCAD. NET Developer ' s Guide2012 edition, official authoritative manual, content too full, too many, not suitable for learning, encountered problems when looking for Use.
C + + Objectarx
AutoCAD Objectarx Development Fundamentals and example tutorials sail, Wenjun 2014-06-01 VC + + 6.0 and VS 2005 arx2002 cad2002
AUTOCAD2010 Two Development Example tutorial (Objectarx) Wang Wenbo April 2013 Mechanical Professional
Highway Engineering CAD:
1. Civil Engineering CAD Technology Tsinghua University Niandichang 2006.5 with CD-ROM P450 comprehensive introduction Cad,arx-based, basic knowledge, the main learning graphics basic algorithm.
2.
Highway Computer-aided Engineering 2000 Zhu Zhaohong : Theory, comparative generalization.
"Guide to Development and application of road survey and design Software" Zhu Zhaohong 2003 Digital Module part good
3. Highway CAD character Zinc sand
4. Road Route CAD Zhu Zhaohong
5. Road Engineering CAD Yang Hongzhi Yu Jiao Hu Jinliang Yan
6. Road and bridge Engineering computer drawing Hu Jinliang record
Road CAD and its use tutorial, engineering example
Highway Engineering CAD Basic Course Zheng Yimin
Computer Aided Engineering Zhang Shuhui
Highway CAD Zhang

This paper was written by the normal distribution X~n (μ,σ2) QQ2052702900 on January 21, 2015, summarizing the knowledge learned in recent days.

"Note" All texts are summaries of individual learning, only if the individual is retained. Jo Jun unfortunate Touring, do not ridicule, there is a merit, may wish to borrow, do not have errors and omissions, but also look at the liberal enlighten.

VS2010 flagship version 2.5G, Classic, Loaded 10G, measured installation c#,c++ and VSTO Total 4.59G
Ultimate Flagship 1.5G, with less MSDN documentation and SQLEXPRESS, has an online installation section. Install without document 3G, with document 13G
Vs2015 about 30G.
If the system has the. NET Framework, that would be a small point. It's automatically loaded without it.
Open Source cad:http://blog.csdn.net/zxgis/article/details/8222729
Pudn Download: http://www.pudn.com/sourcecode/graph/CAD/download210_2.html;
Book Download: http://www.csdn.net/tag/cad%E4%BA%8C%E6%AC%A1%E5%BC%80%E5%8F%91/download

AutoCAD two times Development--autocad.net API Development Environment Construction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.