.NET : How to Get current AutoCAD session

Discussion in 'AutoCAD' started by ngarone, Oct 8, 2004.

  1. ngarone

    ngarone Guest

    Hi all,
    is there a way to get the current AutoCAD session with VB.Net?
    (as we did with GetObject("AutoCad.Application") in VB6)

    Thanks, Nicola
     
    ngarone, Oct 8, 2004
    #1
  2. This works in all .NET languages as it's a call to the base class library:

    System.Runtime.InteropServices.Marshal.GetActiveObject(<progid>)

    I believe VB.NET can still use GetObject.
     
    Frank Oquendo, Oct 8, 2004
    #2
  3. ngarone

    hzdwbm Guest

    'Try to get an open AutoCad object
    Try
    objApp = GetObject(, "AutoCAD.Application.16")
    Catch
    'Try to create an AutoCad object if the previous request failed
    Try
    objApp = CreateObject("AutoCAD.Application.16")
    Catch
    'Error handling
    End Try
    End Try
     
    hzdwbm, Oct 8, 2004
    #3
  4. No. Better to use Frank's method as using the old VB6 approach causes
    problems when exiting the app

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Oct 9, 2004
    #4
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.