Hi, I have embedded AutoCAD inplace activation server control in C# application and trying to get reference of AutoCAD application\drawing object with in C# application. I have added references to acad16enu.tlb,axdb16enu.tlb. Can some helps me in this. I have reference for Active X control of the AutoCAD, how can I get reference for Application and Document with in C#\VB application. Regards, Ramesh V
Hi, Yes, I did. How do I able to get currently running autocad reference with in my c# application. Regards, Ramesh V
Hi Paul, I have added references to acax16enu.tlb, axdb16enu.tlb type libraries and I was able to see Autodesk.AutoCAD.Interop assembly. I was able to see AcadDocument interface and class, AcadApplication interface and classes with in help part, So assuming I can create them with in my application. Would you mind explaining a little bit more here. When I was trying with GetObject method, My application is crashing. Regards, Ramesh
explaining a little bit more here. When I was trying with GetObject Tough to answer without seeing how your doing it...This like should get you started in C# http://discussion.autodesk.com/thread.jspa?messageID=3705449 gl Paul
using System; using System.Runtime.InteropServices; using Autodesk.AutoCAD.Interop; using Autodesk.AutoCAD.Interop.Common; namespace WindowsApplication1 { public class Class1 { public Class1() { AcadApplication acadApp = (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application"); } } } Using acmgd.dll and acdbmgd.dll will allow you to get the instance your assembly is running in but the AcadApplication and AcadDocument COM interfaces are not defined in either of those libraries so you'll still need the COM interop libraries as shown above.
Hi Frank and Paul, Thank you very much for responding. Yes I have added references for COM interop libraries. am getting following error at statement 'AcadApplication acadApp =(AcadApplication)Marshal.GetActiveObject("AutoCAD.Application");' Error Inf: An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll Additional information: Invalid class string Any thoughts. FYI: I have added references to acmgd.dll, acdbmgd.dll and also In COM tab selected references to AutoCAD 2005 type library, AutoCAD/ObjectDBX Common 16.0 Type Libray. Regards, Ramesh
The managed Application object has a static property that will return the COM AcadApplication object. Autodesk.AutoCAD.Interop.AcadApplication acadApp = (AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplic ation; MessageBox.Show(acadApp.Documents.Count.ToString()); -- Bobby C. Jones and I was able to see Autodesk.AutoCAD.Interop assembly. I was able to see AcadDocument interface and class, AcadApplication interface and classes with in help part, So assuming I can create them with in my application. Would you mind explaining a little bit more here. When I was trying with GetObject method, My application is crashing.
Hi, am getting following exception if I try to get static property of COM AcadApplication object. " An unhandled exception of type 'System.IO.FileNotFoundException' occurred in system.windows.forms.dll Additional information: File or assembly name acmgd, or one of its dependencies, was not found." Ramesh V
Hi Everybody, I have added COM interop type libraries AutoCAD 2005 Type Library and AutCAD/ObjectDBX Common 16.0 Type Library. I have imported using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.Interop.Common; using Autodesk.AutoCAD.Interop; am trying to get reference for embedded AutoCAD application using private void button1_Click(object sender, System.EventArgs e){ AcadApplication app = (AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication; } Initially I got a compilation error at static void Main() { Application.Run(new Form1()); -- here I got error. } as ambiguity for Application class, So I have changed it to static void Main() { System.Windows.Forms.Application.Run(new Form1()); } Compilation was fine, when I click the button to get the reference of AutoCAD application am getting following exception at static void Main() { System.Windows.Forms.Application.Run(new Form1()); } The error is : "An unhandled exception of type 'System.IO.FileNotFoundException' occurred in system.windows.forms.dll Additional information: File or assembly name acmgd, or one of its dependencies, was not found." what is the error meaning, why it is saying that it is missing some files. Regards, Ramesh