.NET

.NET

Reply
Contributor
egcallis
Posts: 23
Registered: ‎09-14-2009
Message 1 of 24 (676 Views)

Starting AutoCAD 2012 on a W7 64bit Machine from VS 2010 Express

676 Views, 23 Replies
12-29-2011 07:43 AM

Target Platform is W7 64bit running AutoCAD 2012. Development is with VS 2010 Express.

 

We have a VBA routine the we have been using for 5 years to convert DXFs produced by another 3D package into DWGS. Basically, the program cyles through all the *.dxfs in a folder and changers entitties's layers, colors, modifies text widths, and then scales all by a certain factor.

 

So I've created a VS 2010 Express Windows Application to do this from outside of AutoCad (I couldn't get the code to work as a DLL inside of AutoCAD).

 

Questions:

 

1. Can I use VS 2010 Express to create this application?

  a. If yes, how fo I tell VS 2010 Express to compile for 64bit?

  b. What is the Syntax to start an AutoCAD Application?

 

2. If the answer to 1 is no, can I use VS 2005 Professional to create it?

 

Assuming one of the above answers is yes, which Autodesk components do I need to reference in my VS project?

 

Yes, I've searched this forum for help, but AutoCAD 2012 combined with 64 bit has considerably muddied the waters for me.

 

Fianally, I'm sure I can convibce my boss to upgrade my VS 2005 to 2010 if needed, but don't want to unless it would solve most of the issues. I use VS 2005 for other programs and they compile fine on the 64bit machine I'm using.

 

 

*Expert Elite*
Alfred.NESWADBA
Posts: 9,583
Registered: ‎06-29-2007
Message 2 of 24 (671 Views)

Re: Starting AutoCAD 2012 on a W7 64bit Machine from VS 2010 Express

12-29-2011 07:56 AM in reply to: egcallis

Hi,

 

I tried to search >>>click<<< and one of the first answers point to >>>that link<<< :smileywink:

 

Good luck, - alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Contributor
egcallis
Posts: 23
Registered: ‎09-14-2009
Message 3 of 24 (666 Views)

Re: Starting AutoCAD 2012 on a W7 64bit Machine from VS 2010 Express

12-29-2011 08:02 AM in reply to: Alfred.NESWADBA

Alfred, I've been there but I'm not doing a class dll. And this article dosen't address 64bit issues.

*Expert Elite*
Alfred.NESWADBA
Posts: 9,583
Registered: ‎06-29-2007
Message 4 of 24 (663 Views)

Re: Starting AutoCAD 2012 on a W7 64bit Machine from VS 2010 Express

12-29-2011 08:08 AM in reply to: egcallis

Hi,

 

>> but I'm not doing a class dll

But that's what you need, also your info "I couldn't get the code to work as a DLL inside of AutoCAD" was a question, wasn't it?

Could you describe how your previous app worked? Was it an external EXE that used AutoCAD via ActiveX/COM?

 

>> And this article dosen't address 64bit issues

It's not necessary for most AutoCAD-dotNET-apps to differentiate between 32bit and 64bit, you can leave the project settings set to "Any CPU" and it will work ... once more: valid for dotNET-DLLs!

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Contributor
egcallis
Posts: 23
Registered: ‎09-14-2009
Message 5 of 24 (661 Views)

Re: Starting AutoCAD 2012 on a W7 64bit Machine from VS 2010 Express

12-29-2011 08:14 AM in reply to: Alfred.NESWADBA

No, the DLL inside Autocad was a statement not a question.

 

If you don't use VS2010 Express on a 64bit machine then why are you responding? In other words, we need to seperate issues.

 

For clarity, I'm doing a standalone application that will start an autocad session, do its thing, then close the autocad session.

 

Eric

*Expert Elite*
Alfred.NESWADBA
Posts: 9,583
Registered: ‎06-29-2007
Message 6 of 24 (659 Views)

Re: Starting AutoCAD 2012 on a W7 64bit Machine from VS 2010 Express

12-29-2011 08:17 AM in reply to: egcallis

>> If you don't use VS2010 Express on a 64bit machine then why are you responding?

Sorry for that, I just tried to help. ;(

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Contributor
egcallis
Posts: 23
Registered: ‎09-14-2009
Message 7 of 24 (656 Views)

Re: Starting AutoCAD 2012 on a W7 64bit Machine from VS 2010 Express

12-29-2011 08:20 AM in reply to: Alfred.NESWADBA

If that came across as mean, it was not intended that way. Just want to spend both our resources in an economical way.

*Expert Elite*
norman.yuan
Posts: 1,063
Registered: ‎04-27-2009
Message 8 of 24 (640 Views)

Re: Starting AutoCAD 2012 on a W7 64bit Machine from VS 2010 Express

12-29-2011 10:05 AM in reply to: egcallis

If your goal is to create a stand-alone exe app that automates AutoCAD, yes, VS2010 Express can be used with Acad2012 64-bit, so is VS2005.

 

In general, or by default, a .NET app is built to target ANY CPU, unless you specifically want to limit the app to be built to traget x86, x64 or Itanium. In your case, if you leave pour app targeting ANY CPU, you would not have to worry whether your app runs in Win64 or Win32.

 

Also, in your case, even you build your app specifically for x86 CPU, it still runs with Win64, and it can STILL automate 64-bit AutoCAD, beause it is out-process automation, that is, automated AutoCAD does not run in the same process as your app.

 

The possible issue of COM automation as you planned depends on what is your app's dependecies. Some COM objects used in your app may not be presents/or be the same in the user computer, due to COM's "DLL Hell" issue. And of course, you are limited to AutoCAD's COM API only to automate AutoCAD.

 

Following code is a console app, where I have no issue to start AutoCAD (Acad2012 64-bit)

 

using System;
using Autodesk.AutoCAD.Interop;

namespace AutomateAcad2012
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Press any key to start AutoCAD");
            Console.ReadLine();

            Autodesk.AutoCAD.Interop.AcadApplication cad = new AcadApplication();
            cad.Visible = true;

            Console.WriteLine("Press any key to exit");
            Console.ReadLine();

            cad.Quit();
        }
    }
}

 

If the running computer has more than one version of AutoCAD installed, you would likely have some issue. Yes, COM "DLL Hell" is certainly possble reason, even the PIA (Autodesk.AutoCAD.Interop/Common may seems co-exist in GAC with different versions, but the underline COM DLL the PIA wraps can only be one version, the latest AutoCAD version installed. If your user may use different version of AutoCAD, you'd better ONLY install the oldest version in your development box and develop against it, be it that you use late-binding or not.

 

I am not sure why you refuse to consider doing things inside AutoCAD and insist on out-process automation, considering your previous app is VBA that runs inside AutoCAD. In most cases, automating Acad from stand-alone app is bad choice in comparison to do the same thing inside AutoCAD, unless the automation process is very simple. You need a lot of code to make sure AutoCAD is properly available in the running machine before your task can be performed. While when running inside AutoCAD, when your app can start directly onto your task.

 

Contributor
egcallis
Posts: 23
Registered: ‎09-14-2009
Message 9 of 24 (634 Views)

Re: Starting AutoCAD 2012 on a W7 64bit Machine from VS 2010 Express

12-29-2011 11:08 AM in reply to: norman.yuan

We did it in AutoCAd before because it was easier to develop that way. But all the code does is as listed in my first post. Since we are producing the dxfs from another application, it makes since to me to have them be converted via automation rather than manually opening AutoCad, doing the conversion, then closing autocad.

 

But thanks for the post. Couple of questions:

 

1. What are your project's references?

2. Was this done with VS 2010 Express? If so, any special options?

 

Running the following code gives the error:

+  ex {"Retrieving the COM class factory for component with CLSID {6D7AE628-FF41-4CD3-91DD-34825BB1A251} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE))."} System.Exception

 

 

Code Snippet

Imports Autodesk.AutoCAD.Interop

Imports Autodesk.AutoCAD.Interop.Common


Public ClassMainForm

   

   Public AcadApp AsAcadApplication

   

   Public Sub StartAutoCADSession()       

      Try

                   AcadApp = New AcadApplication() <- Hangs for like 30 secs, then errors

                   AcadApp.Visible =  True

      Catch ex AsException

                   AcadApp = Nothing

               EndTry   

EndSub

 

I attached the project so you can see all the particulars.

 

Thanks again, I'll be googling the error.

Contributor
egcallis
Posts: 23
Registered: ‎09-14-2009
Message 10 of 24 (622 Views)

Re: Starting AutoCAD 2012 on a W7 64bit Machine from VS 2010 Express

12-29-2011 11:39 AM in reply to: egcallis

Another note. Task Manager shows that AutoCad starts. The process is stopped after I stop debugging (after the exception).

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.