.NET

Reply
Mentor
217 Posts
1 Kudo
Registered: ‎08-24-2010
Post 1 of 3
Accepted Solution

Get All Opened Drawings

177 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
231 Posts
30 Kudos
Registered: ‎11-09-2012
Post 2 of 3

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
217 Posts
1 Kudo
Registered: ‎08-24-2010
Post 3 of 3

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