AutoCAD .NET

Discussion in 'AutoCAD' started by vramesh, Jan 24, 2005.

  1. vramesh

    vramesh Guest

    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
     
    vramesh, Jan 24, 2005
    #1
  2. 'reference acmgd.dll
    Imports Autodesk.AutoCAD.ApplicationServices

    gl..
    Paul
     
    Paul Richardson, Jan 24, 2005
    #2
  3. vramesh

    vramesh Guest

    Hi,
    Yes, I did. How do I able to get currently running autocad reference with in my c# application.

    Regards,
    Ramesh V
     
    vramesh, Jan 25, 2005
    #3
  4. You still need COM Interop to access the AcadApplication and
    AcadDocument classes.
     
    Frank Oquendo, Jan 26, 2005
    #4
  5. vramesh

    vramesh Guest

    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
     
    vramesh, Jan 26, 2005
    #5
  6. Paul Richardson, Jan 26, 2005
    #6
  7. 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.
     
    Frank Oquendo, Jan 26, 2005
    #7
  8. vramesh

    vramesh Guest

    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
     
    vramesh, Jan 26, 2005
    #8
  9. 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.
     
    Bobby C. Jones, Jan 26, 2005
    #9
  10. vramesh

    vramesh Guest

    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
     
    vramesh, Jan 26, 2005
    #10
  11. vramesh

    vramesh Guest

    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
     
    vramesh, Jan 26, 2005
    #11
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.