You can try this way (if the file isn't already saved, db.Filename returns the template path):
Error 3 'GetSystemVariable' is not a member of 'Autodesk.AutoCAD.ApplicationServices.Document'.
Error 4 'EditorWriteMessage' is not a member of 'Autodesk.AutoCAD.ApplicationServices.Document'.
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Imports System.IO
Public Class Class1
<CommandMethod("PS")> _
Public Sub DrawingPath()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim h_app As HostApplicationServices = HostApplicationServices.Current
Dim title As Integer = Convert.ToInt32(doc.GetSystemVariable("DWGTITLED"))
If title > 0 Then
Dim path As String = h_app.FindFile(doc.Name, doc.Database, FindFileHint.[Default])
Dim info As New FileInfo(path)
Dim size As Long = info.Length
doc.Editor.WriteMessage(vbLf & "Path: " & path)
doc.EditorWriteMessage(vbLf & "FileSize: " & size)
Else
doc.Editor.WriteMessage(vbLf & "File not found")
End If
End Sub
End Class
Yup,You shouldn't wrap the Application in a Using statement. The Application scope is outside your method and AutoCAD is handling its disposal.
The using statement for AcadApp is:
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
Then:
AcadApp.GetSystemVariable("DwgTitled");
Thanks Jeff!
Yup,You shouldn't wrap the Application in a Using statement. The Application scope is outside your method and AutoCAD is handling its disposal.
The using statement for AcadApp is:
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
Then:
AcadApp.GetSystemVariable("DwgTitled");
Thanks Jeff!
I think the 'using' here isn't a 'statement', rather a 'directive' used to define an alias (see here (https://msdn.microsoft.com/en-us/library/zhdeatwt.aspx))
Er, yes, I should have said directive not statement. My bad.
Learn something new everyday!
Thanks.
Yup,Your Welcome
The using statement for AcadApp is:
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
Then:
AcadApp.GetSystemVariable("DwgTitled");
Thanks Jeff!