+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Forum Newbie
    Using
    Map 3D 2010
    Join Date
    Aug 2008
    Posts
    8

    Default Check Instances of AutoCad for Open Documents

    Registered forum members do not see this ad.

    What I am trying to do is check all the instances of Autocad that are running and check for all of the open documents in each one. I have this working in VB6 but .NET is giving me problems. I can get the MainWindowTitle but the other documents open for that instance I have not been able to figure out. Sorry if this has been posted before but I am not sure if I am even on the right track. Any suggestions for this in .NET? I would prefer not to use GetObject(, "Autocad.Application"). Thanks Everybody

  2. #2
    Full Member
    Discipline
    Electrical
    btraemoore's Discipline Details
    Occupation
    Electrical Designer
    Discipline
    Electrical
    Using
    Electrical 2012
    Join Date
    Apr 2012
    Location
    Houston
    Posts
    55

    Default

    Just out of curiosity, why don't you want to use the getobject method?

  3. #3
    Forum Newbie
    Using
    Map 3D 2010
    Join Date
    Aug 2008
    Posts
    8

    Default

    Because it does not want to work, I was looking for other options, I wanted to move out of the VB6 era. I am using VS2008 so I may not have any other options. I am trying to find out. Thanks again.

  4. #4
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,948

    Default

    FWIW -

    You may find this old post useful as an example of how to get an existing instance, or create a new instance of an application:

    Quote Originally Posted by RenderMan View Post
    Sounds like you need to check for an active process, prior to creating a new instance.

    Here's a VB.NET snippet from one of my projects, for you to pull from:

    Code:
    Imports Excel = Microsoft.Office.Interop.Excel
    Imports Microsoft.Office.Interop
    
    Imports System.Diagnostics
    Imports System.IO
    
    Module FOO
    
        Sub Excel_Foo()
    
            Dim xlApp As Excel.Application
    
            Try
                ' Look for an existing process, if available getObject
                If Process.GetProcessesByName("Excel").Length > 0 Then
                    xlApp = CType(GetObject(, "Excel.Application"), Excel.Application)
                ' Else createObject
                Else
                    xlApp = New Excel.Application
                End If
    
                ' <-- Do something
    
            Catch ex As Exception
    
            Finally
                xlApp = Nothing
    
        End Sub
    
    End Module
    "Potential has a shelf life." - Margaret Atwood

  5. #5
    Forum Newbie
    Using
    Map 3D 2010
    Join Date
    Aug 2008
    Posts
    8

    Default

    It is the Do Something I am trying to figure out.
    This returns the MainWindowTitle
    AutoCAD Map 3D 2010 - [Drawing1.dwg] First instance
    AutoCAD Map 3D 2010 - [A5119.DWG] Second Instance
    If I have multiple files open in each instance I want the WindowTitle for each one.

    Dim p() As Process = Process.GetProcessesByName("Acad")
    ForEach proc As Process In p
    Debug.Print(proc.MainWindowTitle)
    For Each AcadDocument in proc...?
    Next

    Iterate through each instance and each document and return the window title.

  6. #6
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,948

    Default

    Instead, why not simply iterate the Documents Collection for each instance of AutoCAD?

    Perhaps this will be helpful: Control the Drawing Windows
    "Potential has a shelf life." - Margaret Atwood

  7. #7
    Forum Newbie
    Using
    Map 3D 2010
    Join Date
    Aug 2008
    Posts
    8

    Default

    That is what I am trying to do.

  8. #8
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,948
    "Potential has a shelf life." - Margaret Atwood

  9. #9
    Forum Newbie
    Using
    Map 3D 2010
    Join Date
    Aug 2008
    Posts
    8

    Default

    What if none of these will import?
    'Imports Autodesk.AutoCAD.Runtime
    'Imports Autodesk.AutoCAD.ApplicationServices
    'Imports Autodesk.AutoCAD.DatabaseServices
    'Imports Autodesk.AutoCAD.EditorInput

  10. #10
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,948

    Default

    Registered forum members do not see this ad.

    Then you're missing Assembly Reference(s).

    ... In Solution Explorer, Select the 'Show All Files' button, and expand the References node... Within, you should have AcDbMgd.dll, and AcMgd.dll added (be sure they both have 'Copy Local' = False in the Properties window).

    If you do not know what these Assembly References are, see this thread.
    "Potential has a shelf life." - Margaret Atwood

Similar Threads

  1. how to check if CAD is OPEN AND READY
    By inneedofmajorhelp in forum .NET, ObjectARX & VBA
    Replies: 16
    Last Post: 14th Dec 2011, 12:16 am
  2. I need a way to check if a pdf file is open?
    By hemuni in forum AutoLISP, Visual LISP & DCL
    Replies: 12
    Last Post: 27th Jul 2011, 12:42 pm
  3. Check if app already open?
    By Small Fish in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 17th Aug 2009, 09:48 pm
  4. Autocad documents online.
    By gjensen01 in forum Useful Links
    Replies: 3
    Last Post: 27th Oct 2005, 09:40 pm
  5. Open Multiple Instances of AutoCAD version 13
    By cmias in forum AutoCAD Drawing Management & Output
    Replies: 11
    Last Post: 9th Oct 2003, 01:52 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts