Imports AutoCAD
Imports AutoCAD.AcadDocumentClass
Module Module1
Sub Main()
Dim NovellPath As String = "\\my_novell_path\dwg\"
Dim strFileName As String = NovellPath & "my_dwgfile.dwg"
Dim vAcadApp As AutoCAD.AcadApplication
Dim vAcadDoc As AutoCAD.AcadDocument
Try
'Look for an existing process if availabe getObject
If Process.GetProcessesByName("acad").Length > 0 Then
vAcadApp = CType(GetObject(, "Acad.Application"), AcadApplication)
'Else createObject
Else
vAcadApp = New AutoCAD.AcadApplication
vAcadApp.Visible = True
vAcadApp.WindowState = AutoCAD.AcWindowState.acMax
vAcadDoc = vAcadApp.Documents.Open(strFileName, False)
End If
vAcadApp.Open(strFileName, True)
Catch ex As Exception
End Try
End Sub
End Module
Doesn't the Open() Method need to be invoked upon the Document Collection Object, and not the Application Object?
Also, you might consider doing 'something' with the Exception(s) you Catch (and look for any Exceptions for Methods you invoke elsewhere in your code as well)... Pseudo example:Code - vb.net: [Select]
' <snip> Catch ex As Autodesk.AutoCAD.Runtime.Exception ed.WriteMessage(vbLf & "AutoCAD error: {0}" & vbLf, ex.Message) Return Nothing Catch ex As System.Exception ed.WriteMessage(vbLf & "System error: {0}" & vbLf, ex.Message) Return Nothing End Try ' <snip>
Imports AutoCAD
Imports AutoCAD.AcadDocumentClass
Module Module1
Sub Main()
Dim vAcadApp, vNewFile As Object
Dim strNovellPath As String = "\\my_novell_path\dwg\"
Dim strFileName As String = "drawing templates(xx).dwg"
On Error Resume Next
vAcadApp = GetObject(, "autocad.Application")
If Err.Number <> 0 Then
Err.Clear()
vAcadApp = CreateObject("autocad.Application")
End If
vAcadApp.Visible = True
Err.Clear()
vNewFile = vAcadApp.Documents.Open(strNovellPath & strFileName, False)
End Sub
End Module
Doesn't the Open() Method need to be invoked upon the Document Collection Object, and not the Application Object?
Heck the code in the new 2013 .NET Developer's Guide won't even work unless you make major changes to the syntax based on all the recent changes.