.NET

Reply
Mentor
Amremad
Posts: 217
Registered: ‎08-24-2010
Message 1 of 3 (168 Views)
Accepted Solution

Get All Opened Drawings

168 Views, 2 Replies
02-11-2014 05:01 AM

hello all 

 

i need create an array with variable length and in DocumentCreated event add the new drawing to this array 

some thing like this but i can't complete all code 

 

Dim doc() As Autodesk.AutoCAD.ApplicationServices.Document
Dim WithEvents curDwg As Autodesk.AutoCAD.DatabaseServices.Database = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase

Private Sub DocumentCreated(sender As Object, e As DocumentCollectionEventArgs) Handles DwgIO.DocumentCreated ReDim doc(doc.Count + 1) doc(doc.Length).Database = e.Document.Database End Sub

 thanks

 Public Structure OpenedDocuments
Dim cDocument As Autodesk.AutoCAD.DatabaseServices.Database
Dim Duration As Integer
End Structure
Dim cDocuments(0) As OpenedDocuments
Private Sub DocumentCreated(sender As Object, e As DocumentCollectionEventArgs) Handles DwgIO.DocumentCreated
' Append opened current drawing to the array
cDocuments(cDocuments.Length - 1).cDocument = e.Document.Database
ReDim Preserve cDocuments(cDocuments.Length)
End Sub

 this is my solution and work good

Mentor
mzakiralam
Posts: 231
Registered: ‎11-09-2012
Message 2 of 3 (161 Views)

Re: Get All Opened Drawings

02-11-2014 05:59 AM in reply to: Amremad

Hi, you can not make array of a document object. If you want to get all the open drawing , you have to use following code:

 

  Dim docs As DocumentCollection = Application.DocumentManager

  You can also find the no of document are open with following code:

 

 Dim docNumber As Integer = docs .Count 

 

Mentor
Amremad
Posts: 217
Registered: ‎08-24-2010
Message 3 of 3 (123 Views)

Re: Get All Opened Drawings

02-12-2014 04:03 AM in reply to: Amremad
    Public Structure OpenedDocuments
        Dim cDocument As Autodesk.AutoCAD.DatabaseServices.Database
        Dim Duration As Integer
    End Structure

    Dim cDocuments(0) As OpenedDocuments
    Private Sub DocumentCreated(sender As Object, e As DocumentCollectionEventArgs) Handles DwgIO.DocumentCreated

        ' Append opened current drawing to the array
        cDocuments(cDocuments.Length - 1).cDocument = e.Document.Database
        ReDim Preserve cDocuments(cDocuments.Length)
    End Sub

 this is my solution and work good

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.