.NET
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
ThisDrawin g.Path equivalent
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
863 Views, 12 Replies
01-05-2010 05:29 AM
What's the equivalent of ThisDrawing.Path in VB.NET?
Here's what I think it should be... but it's not working:
Dim AcadDoc As Document = Application.DocumentManager.MdiActiveDocument
AcadDoc.Path? or GetPath?
Slowly learning... thanks for the help.
eric
Here's what I think it should be... but it's not working:
Dim AcadDoc As Document = Application.DocumentManager.MdiActiveDocument
AcadDoc.Path? or GetPath?
Slowly learning... thanks for the help.
eric
Re: ThisDrawin g.Path equivalent
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-05-2010 07:41 AM in reply to:
aielli
In C# i did it this way:
AcadApplication oAcadApp = (AcadApplication)Autodesk.AutoCAD.ApplicationServi ces.Application.AcadApplication;
String sFilePath = oAcadApp.ActiveDocument.Path + "\\" + oAcadApp.ActiveDocument.Name;
so, In VB.NET I think it would be like this:
Dim oAcadApp as AcadApplication
Dim sFilePath as String
Set oAcadApp = Autodesk.AutoCAD.ApplicationServices.Application.A cadApplication;
sFilePath = oAcadApp.ActiveDocument.Path & "\" & oAcadApp.ActiveDocument.Name;
The path is only the path and the name is only the name.
AcadApplication oAcadApp = (AcadApplication)Autodesk.AutoCAD.ApplicationServi
String sFilePath = oAcadApp.ActiveDocument.Path + "\\" + oAcadApp.ActiveDocument.Name;
so, In VB.NET I think it would be like this:
Dim oAcadApp as AcadApplication
Dim sFilePath as String
Set oAcadApp = Autodesk.AutoCAD.ApplicationServices.Application.A
sFilePath = oAcadApp.ActiveDocument.Path & "\" & oAcadApp.ActiveDocument.Name;
The path is only the path and the name is only the name.
Re: ThisDrawin g.Path equivalent
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-05-2010 11:03 AM in reply to:
aielli
Thanks, but I don't believe that ActiveDocument is a property of AcadApplication.
I'm using AutoCAD 2010... not sure if this has changed...
I'm using AutoCAD 2010... not sure if this has changed...
Re: ThisDrawin g.Path equivalent
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-05-2010 11:24 AM in reply to:
aielli
This works in 2010
{code}
Dim oAcadApp As Autodesk.AutoCAD.ApplicationServices.Document
oAcadApp = Autodesk.AutoCAD.ApplicationServices.Application.D ocumentManager.MdiActiveDocument
MsgBox(oAcadApp.Name)
{code}
{code}
Dim oAcadApp As Autodesk.AutoCAD.ApplicationServices.Document
oAcadApp = Autodesk.AutoCAD.ApplicationServices.Application.D
MsgBox(oAcadApp.Name)
{code}
---------------------------

“We don’t have a snowball’s chance in a blast furnace of surviving this attack unless every one of our units gets into the fight right now!”

“We don’t have a snowball’s chance in a blast furnace of surviving this attack unless every one of our units gets into the fight right now!”
Re: ThisDrawin g.Path equivalent
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-05-2010 11:52 AM in reply to:
aielli
Thank you!
Didn't realize that the Name property gave the full path.
Didn't realize that the Name property gave the full path.
Re: ThisDrawin g.Path equivalent
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-05-2010 12:05 PM in reply to:
aielli
AcadDoc.Name was the reply I gave in your duplicated post:
http://discussion.autodesk.com/forums/thread.jspa? threadID=757438&tstart=0
> Thanks, but I don't believe that ActiveDocument is a property of AcadApplication.
Yes it is, but DeanLyon is using COM interop rather than .NET API
http://discussion.autodesk.com/forums/thread.jspa?
> Thanks, but I don't believe that ActiveDocument is a property of AcadApplication.
Yes it is, but DeanLyon is using COM interop rather than .NET API
Gilles Chanteau
Re: ThisDrawin g.Path equivalent
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-05-2010 10:48 PM in reply to:
aielli
As mentioned above, This works with COM in 2010
{code}
Dim oAcadApp As Autodesk.AutoCAD.Interop.AcadApplication
Try
oAcadApp = GetObject(, "AutoCAD.Application.18")
Dim sFilePath As String
sFilePath = oAcadApp.ActiveDocument.Path & "\" & oAcadApp.ActiveDocument.Name
MsgBox(sFilePath)
Catch ex As Exception
oAcadApp = Nothing
End Try
{code}
{code}
Dim oAcadApp As Autodesk.AutoCAD.Interop.AcadApplication
Try
oAcadApp = GetObject(, "AutoCAD.Application.18")
Dim sFilePath As String
sFilePath = oAcadApp.ActiveDocument.Path & "\" & oAcadApp.ActiveDocument.Name
MsgBox(sFilePath)
Catch ex As Exception
oAcadApp = Nothing
End Try
{code}
---------------------------

“We don’t have a snowball’s chance in a blast furnace of surviving this attack unless every one of our units gets into the fight right now!”

“We don’t have a snowball’s chance in a blast furnace of surviving this attack unless every one of our units gets into the fight right now!”
Re: ThisDrawin g.Path equivalent
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-13-2011 08:04 AM in reply to:
aielli
Is there an equivalent for the .path for the .NET API? I don't have COM installed
I'm looking for it a couple days now but can't find a way to do it.
Re: ThisDrawin g.Path equivalent
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-13-2011 09:25 AM in reply to:
aielli
Whoa -- no need for COM.
Document doc = Application.DocumentManager.MdiActiveDocument; string path = Path.GetDirectoryName(doc.Database.Filename);
Re: ThisDrawin g.Path equivalent
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-13-2011 12:15 PM in reply to:
aielli
What about the "DWGPREFIX" system variable, it's easy to check in both .NET and COM interop.


