.NET

Reply
Valued Contributor
NKCAUTOCAD01
Posts: 86
Registered: ‎08-31-2011
Message 1 of 4 (199 Views)
Accepted Solution

Document Object by a drawing file name

199 Views, 3 Replies
11-27-2012 09:29 PM

In AutoCAD.NET API, please tell me.

From DocumentManager, I want to acquire Document Object by a drawing file name. 

Please tell me the method.

I would like it in VB.NET if possible.
Thanking you in advance.

Think you need all documents what is already opened

then you can try this code

 

 <CommandMethod("tfl")> _
Public Sub testDrawings()
Dim dm As DocumentCollection = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager
Dim doc As Document = dm.GetDocument(HostApplicationServices.WorkingDatabase)
Dim ed As Editor = doc.Editor
ed.WriteMessage(vbLf + "Current Document: {0}", doc.Name)
Dim ienum As IEnumerator = dm.GetEnumerator
While ienum.MoveNext
Dim idoc As Document = DirectCast(ienum.Current, Document)
ed.WriteMessage(vbLf + " Document item in collection: {0}", idoc.Name)
End While
End Sub

 

 

 

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 4 (191 Views)

Re: Document Object by a drawing file name

11-28-2012 01:57 AM in reply to: NKCAUTOCAD01

Think you need all documents what is already opened

then you can try this code

 

       <CommandMethod("tfl")> _
        Public Sub testDrawings()

            Dim dm As DocumentCollection = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager
            Dim doc As Document = dm.GetDocument(HostApplicationServices.WorkingDatabase)
            Dim ed As Editor = doc.Editor
            ed.WriteMessage(vbLf + "Current Document: {0}", doc.Name)

            Dim ienum As IEnumerator = dm.GetEnumerator
            While ienum.MoveNext
                Dim idoc As Document = DirectCast(ienum.Current, Document)
                ed.WriteMessage(vbLf + " Document item in collection: {0}", idoc.Name)
            End While

        End Sub

 

 

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Valued Contributor
NKCAUTOCAD01
Posts: 86
Registered: ‎08-31-2011
Message 3 of 4 (172 Views)

Re: Document Object by a drawing file name

11-28-2012 04:43 PM in reply to: NKCAUTOCAD01

Dear Mr. Hallex
Thank you for immediate advice.

It was saved very much.Yours sincerely,
NKCAUTOCAD01 (M.Tsukamoto).

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 4 of 4 (165 Views)

Re: Document Object by a drawing file name

11-28-2012 09:23 PM in reply to: NKCAUTOCAD01

You're welcome, M.Tsukamoto

Keep coding,

Cheers :smileyhappy:

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!