*Expert Elite*
Posts: 1,045
Registered: ‎04-27-2009
Message 1 of 5 (198 Views)

AutoCAD console EXE with managed map API

198 Views, 4 Replies
05-08-2014 01:21 PM

While this is more of AutoCAD Map question, but may also apply to other AutoCAD vertical products that many of us .NET API programming use.


Does any one know whther one can write some managed API code with Map functionality (defined in ManagedMapApi.dll), such accessing ObjectData, attaching/detaching drawings and run with AutoCAD console EXE (of course the computer has AutoCAD Map 2013, not a vanilla AutoCAD, or later installed)?


While I can spend some time to try it out, I thought someone may have already tried.

Posts: 211
Registered: ‎07-20-2011
Message 2 of 5 (179 Views)

Re: AutoCAD console EXE with managed map API

05-08-2014 11:22 PM in reply to: norman.yuan

Maybe this idea might help you to get on track.


I had more or less the same problem: i needed some funtionality of a document management system in my AutoCAD program.

However that document management program may or may not be installed so i don't  want to add references to these libraries.


My solution is building a separate class with this (managed) document management functionality and then dynamically load this when required.

You can also generate+compile+load this code while running you're program. 



*Expert Elite*
Posts: 1,045
Registered: ‎04-27-2009
Message 3 of 5 (117 Views)

Re: AutoCAD console EXE with managed map API

07-03-2014 01:09 PM in reply to: norman.yuan

I finally found a bit time and tried, got the answer:


No, I cannot use Map ObjectARX API with AutoCAD console EXE.


More details:


1. I have AutoCAD Map 2015 installed.

2. I wrote a simple .NET Add-in DLL, which has a command defined to count block reference with give block name, and write the count to an external file.

3. I created a simple AutoCAD script, which do (a), NETLOAD the .NET DLL and (b) call the command defined in the .NET DLL

4. run accoreconsole.exe with a drawing file anme and the script file anme as arguments. The .NET command executed correctly and the block count was written into the external file.

5. In the command method, add a couple of lines of code to call API defined in Map ObjectARX API (getting MapApplication, which is the very basic step of doing Acad Map work). 

6. Run accoreconsole.exe with the same arguments. 

7. In the "DOS" window, I noticed there is error message showing before the "DOS" window closed down. Examine the external file, the block count was correctly written. That means, the code worked in the console until call to Map API.


In order to debug what error occurs when console app runs into Map API call, I used Windows.Forms.MessageBox in try...catch... block to hold the console app. Indeed, the message box pops up during console execution and only continue after the message box dismissed. The message box in the catch... clause let me know that it is the first line of code that call Map .NET API raised the exception and said the operaion is not valid. So, it looks like console app can only be used to do vanilla AutoCAD stuff.


I hope someone from ADN development support could confirm this.



ADN Support Specialist
Posts: 101
Registered: ‎06-15-2011
Message 4 of 5 (105 Views)

Re: AutoCAD console EXE with managed map API

07-03-2014 10:23 PM in reply to: norman.yuan



You can not use MapApplication in accoreconsole.exe. infact you should not use AcadApplication in accoreconsole.exe. I will say refer http://adndevblog.typepad.com/autocad/2012/04/getting-started-with-accoreconsole.html .

Virupaksha Aithal KM
Developer Technical Services
Autodesk Developer Network

*Expert Elite*
Posts: 1,045
Registered: ‎04-27-2009
Message 5 of 5 (87 Views)

Re: AutoCAD console EXE with managed map API

07-04-2014 06:30 AM in reply to: Virupaksha.aithal

Thank you for confirming this.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!