.NET

Reply
Valued Contributor
GrzesiekGP
Posts: 67
Registered: ‎02-03-2012
Message 1 of 4 (211 Views)

WinForm/WPF and AutoCAD 2007 & 2011.

211 Views, 3 Replies
03-20-2012 12:50 AM

Hello!

 

I have standalone application. With this app I'm startin an AutoCAD 2007.

 

  const string progID = "AutoCAD.Application.17";
          
            AcadApplication acApp = null;
            try
            {
                acApp = (AcadApplication)Marshal.GetActiveObject(progID);
            }
            catch
            {
                try
                {
                    Type acType = Type.GetTypeFromProgID(progID);
                    acApp = (AcadApplication)Activator.CreateInstance(acType, true);
                }
                catch
                {
                    MessageBox.Show("Cannot create object of type \"" + progID + "\"");
                }
            }
            if (acApp != null)
            {
                // By the time this is reached AutoCAD is fully
                // functional and can be interacted with through code
                acApp.Visible = true;
                acApp.ActiveDocument.SendCommand(....);
....
            }

 

 

I've added references to the AutoCAD 2007 Type Library and ObjectDBX (2007).

 

But I want to have my application compatibile with AutoCAD 2011. With detection which AutoCAD is installed I don't have any problems.

 

But how can I add the references depending on AutoCAD version? I tried to add both, but this is impossible.

 

I was thinking about dynamically loading assemblies, but how can I then call AutoCAD and SendCommand?

 

Thanks for the help.

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 4 (207 Views)

Re: WinForm/WPF and AutoCAD 2007 & 2011.

03-20-2012 01:59 AM in reply to: GrzesiekGP

Type in the command lIne ACADVER

you will be get a current version of your

AutoCAD installed

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Valued Contributor
GrzesiekGP
Posts: 67
Registered: ‎02-03-2012
Message 3 of 4 (206 Views)

Re: WinForm/WPF and AutoCAD 2007 & 2011.

03-20-2012 02:03 AM in reply to: Hallex

With version detection I don't have problems as I said, but thanks.

That's nice tricky command :smileywink:

 

The question is about assemblies references and differents versions.

Valued Contributor
GrzesiekGP
Posts: 67
Registered: ‎02-03-2012
Message 4 of 4 (181 Views)

Re: WinForm/WPF and AutoCAD 2007 & 2011.

03-20-2012 08:18 AM in reply to: GrzesiekGP

Or maybe other question:

 

How can I send command to the autocad without declaring its version? So the code will be compatibile for both AC 2007 and 2011. 

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.