.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Connecting to AutoCAD
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I have a .NET app that I have created to run inside of AutoCAD. It runs inside of AutoCAD and has been tested on both AutoCAD 2010 and 2012. I have also built a standalone applicaiton that is intended to start AutoCAD and netload the in process dll. I have a computer that has 2010 installed and if I compile the application on this machine everything works as it should. If I then run the same standalone application on a computer that only has 2012 installed it doesn't connect. It starts AutoCAD (acad.exe shows up in the task manager) but it can't connect to it. I then tested the opposite scenario. Built the standalone application on a computer that only has 2012 installed and it works with AutoCAD 2012. I then ran that applicaiton on the computer with only AutoCAD 2010 installed and it can't connect. Just like before, acad.exe is started but it doesn't connect and instead gives an error.
Obviously this would make supporting different versions of AutoCAD require a different executables for the standalone application which seems wrong. I have created a applicaiton that communicates with Inventor and this problem did not occur. Thus, I had assumed it wouldn't be an issue with AutoCAD. Am I doing something wrong that is preventing the different versions from working? Any help would be greatly appreciated.
Re: Connecting to AutoCAD
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
If you post the code from the stand-alone app that starts AutoCAD then netloads the in-process dll you might get a better response.
Re: Connecting to AutoCAD
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Here is the code for connecting to AutoCAD.
public void connectAutoCad()
{
String progID = "Application.AutoCAD";
try
{
//try to connect an open instance of autoCad
acApp = (AcadApplication)Marshal.GetActiveObject(progID);
}
catch
{
//open a new instance autoCad
Type acType = Type.GetTypeFromProgID(progID);
acApp =(AcadApplication)Activator.CreateInstance(acType,true);
}
}
Re: Connecting to AutoCAD
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi cvaught,
Have you tried setting the visibility using "acApp.Visible = true" after "CreateInstance" call ?
Does AutoCAD then show up ?
Balaji
Developer Technical Services
Autodesk Developer Network
Re: Connecting to AutoCAD
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
It throws an exception on that line. Thus acApp is null.
Re: Connecting to AutoCAD
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
I have 2011 and 2012 installed and it works ok when i launch 2012.
Here are few things that you may try :
1) Check the following in the registry - HKEY_CLASSES_ROOT\AutoCAD.Application
Use the CLSID mentioned to search and this should lead you to the acad.exe path that is supposed to get launched. Make sure you do this carefully and dont change anything by mistake.
2) Try invoking a specific version by providing a different progId such as "AutoCAD.Application.18" and "AutoCAD.Application.18.2".
3) See if the issue is specific to a system by trying it on other systems that only have 2012.
Balaji
Developer Technical Services
Autodesk Developer Network
Re: Connecting to AutoCAD
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
So just to confirm, a single excutable that is created on a computer using AutoCAD 2012 should be able to connect to AutoCAD when the application is installed on a computer that only contains AutoCAD 2010?
Re: Connecting to AutoCAD
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I still haven't found a solution for my problem. Does anyone have experience with connecting to multiple different versions of AutoCAD with a single executable? Any help would be greatly appreciated.
Re: Connecting to AutoCAD
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Try to get the current version something like this
{code}
Dim acadver As Object
acadver = My.Computer.Registry.GetValue("HKEY_CLASSES_ROOT\A
String.Empty, String.Empty)
If typeOf acadver Is String Then
MessageBox.Show("String acadver: " & acadver.ToString
end if
{code}
Then pull this string to CreateInstance method from
System.Reflection namespace
~'J'~
C6309D9E0751D165D0934D0621DFF27919
Re: Connecting to AutoCAD
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Same problem still exists. It starts acad.exe but cannot connect to it. Any other opitons? This seems like it should be pretty straight forward. How else can a stand along application support multiple versions of AutoCAD?



