See the top rated post in this thread. Click here

Results 1 to 2 of 2

Thread: How to wait for AutoCAD to be ready?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Login to Give a bone
    0

    Default How to wait for AutoCAD to be ready?

    If I run the "OpenDrawing" from a command prompt inside of AutoCAD (after AutoCAD is "ready") everything works perfectly. However, if I try to run the "OpenDrawing" subroutine as part of the "autoload" functionality I get most of the message boxes, but the drawing doesn't open. I feel this is because AutoCAD is not "all the way open" when the subroutine executes. Does anyone have an idea how to resolve this issue?

    Code:
    Imports System.Windows.Forms
    
    Imports Autodesk.AutoCAD.Runtime
    
    Imports Autodesk.AutoCAD.ApplicationServices
    
    Imports System.IO
    
    Public Class clsInitialize
    
        Implements Autodesk.AutoCAD.Runtime.IExtensionApplication
    
        Public Sub subInitialize() Implements IExtensionApplication.Initialize
    
            MsgBox("Plugin loaded successfully . . .")
    
            OpenDrawing()   'IF THIS LINE IS OMITTED,
    
        End Sub
    
        Public Sub subTerminate() Implements IExtensionApplication.Terminate
    
            MsgBox("Plugin unloaded . . . ")
    
        End Sub
    
        <CommandMethod("OpenDrawing", CommandFlags.Session)> _
        Public Sub OpenDrawing()
    
            Dim strDrivePathNameExt As String
    
            Dim colAcadDocs As DocumentCollection   'ApplicationServices
    
            MsgBox("OpenDrawing Sub")
    
            strDrivePathNameExt = "C:\Temp\Junk.dwg"
    
            colAcadDocs = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager
    
            MsgBox("Here1")
    
            If (File.Exists(strDrivePathNameExt)) Then   'System.IO
    
                MsgBox("Here2")
    
                DocumentCollectionExtension.Open(colAcadDocs, strDrivePathNameExt, False)
    
                MsgBox("File " & strDrivePathNameExt & " opened.")
    
            Else
    
                MsgBox("File " & strDrivePathNameExt & " does not exist.")
    
            End If
    
            MsgBox("Here3")
    
        End Sub
    
    End Class
    Last edited by Ed Jobe; 2019-06-07 at 02:13 PM. Reason: Added CODE tags

Similar Threads

  1. How to place beams on multiple floors. But wait, it's not that simple!
    By ppirtle in forum Revit Structure - General
    Replies: 4
    Last Post: 2009-06-08, 06:09 PM
  2. This is a good thing....can't wait!!!
    By dellis in forum DV - The 3rd Dimension
    Replies: 0
    Last Post: 2008-10-30, 08:32 PM
  3. How long do you wait for Support Requests?
    By Andre Baros in forum Revit Architecture - General
    Replies: 16
    Last Post: 2008-04-28, 08:05 AM

Posting Permissions

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