.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Current Drawing Location Path

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
7381 Views, 4 Replies

Current Drawing Location Path

Hi Guys,

 

I am using vb.net and I need to find the directory path that my current or open drawing is located in.  I'm not sure how to get this from vb.net.  Any help is appreciated.   Thanks.

4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

Take a look at

Document.Name

Database.OriginalFileName

 

        <CommandMethod("GetFileName")> _
        Sub GetFileName()
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor

            ed.WriteMessage(doc.Name & vbCrLf)
            ed.WriteMessage(db.OriginalFileName)

        End Sub

 

 

Message 3 of 5
Anonymous
in reply to: Anonymous

Sorry you want the folder,

 

 

 Application.GetSystemVariable("DWGPREFIX")

 

or another way

make sure you Import System.IO

Change previos Post to

 <CommandMethod("GetFileName")> _
        Sub GetFileName()
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor
            ed.WriteMessage(Path.GetDirectoryName(doc.Name) & vbCrLf)
            ed.WriteMessage(Path.GetDirectoryName(db.OriginalFileName))
        End Sub

 

 

 

 

Message 4 of 5
Anonymous
in reply to: Anonymous

Thank you for your post.  This is exactly what i was looking for.  I have a another question now that I'm seeing the output of this.  Is there a way to go up one folder level in the directory path?  Or i would have to manually trim the string?

Message 5 of 5
Anonymous
in reply to: Anonymous

        <CommandMethod("GetFileName")> _
        Sub GetFileName()
            Dim doc As Document = Application.DocumentManager.MdiActiveDocument
            Dim db As Database = doc.Database
            Dim ed As Editor = doc.Editor

            ed.WriteMessage(Path.GetDirectoryName(doc.Name) & vbCrLf)
            ed.WriteMessage(Path.GetDirectoryName(db.OriginalFileName) & vbCrLf)


            Dim fpath As String = Path.GetDirectoryName(doc.Name)


            While fpath <> Nothing
                ed.WriteMessage(fpath & vbCrLf)
                fpath = Path.GetDirectoryName(fpath)
            End While

            fpath = doc.Name
            Dim levels As Integer = ed.GetInteger("Enter number of levels you want" & vbCrLf).Value

            For i As Integer = 0 To levels
                fpath = Path.GetDirectoryName(fpath)
                If fpath = Nothing Then
                    Exit For
                End If
            Next
            ed.WriteMessage(fpath & vbCrLf)

        End Sub

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report