documentcollection ??

documentcollection ??

Anonymous
Not applicable
598 Views
3 Replies
Message 1 of 4

documentcollection ??

Anonymous
Not applicable

Hi to everybody,

 

i'm pretty new to .NET customization for AutoCAD, i've just made some small VBA tools for previous ACAD versions, so i hope somebody could help me with my problem Smiley Wink

 

I have a Form with a "combobox" and i want to assign the names of the opened DWG's to that "combobox".

 

In an old VBA tool i'm using that code:

 

    Dim DWGCount As Integer
    DWGCount = ThisDrawing.Application.Documents.Count
    
    Dim mThisDwgName As String
    mThisDwgName = ThisDrawing.Name
    
    Dim DWGIndex As Integer
    Dim mDwgName As String
    
    For DWGIndex = 0 To DWGCount - 1
        mDwgName = ThisDrawing.Application.Documents(DWGIndex).Name
        If mThisDwgName <> mDwgName Then Me.cmbDWGSelection.AddItem.mDwgName
    Next DWGIndex

 

and in .NET ;

 

  Dim DWGCount As Integer = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Count
              Dim acDoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim mThisDWGName As String
        Dim DWGindex As Integer
        Dim mDWGName As String

        mThisDWGName = acDoc.Name

        For DWGindex = 0 To DWGCount - 1
            mDWGName = XXX (i dodnt know, what to do here....)
            If mThisDwgName <> mDwgName Then cmbModelDwg.Items.Add(mDwgName)
        Next

 

 as you can see, i dont know, how to get the opend drawings, to iterate them and get the name.....

 

Greetings

Manuel

0 Likes
599 Views
3 Replies
Replies (3)
Message 2 of 4

arcticad
Advisor
Advisor

 

    Public Sub myList()
        Dim lstDWG As New List(Of String)
        If getDrawingList(lstDWG) Then
            For Each item As String In lstDWG
                MsgBox(item)
            Next
        End If
    End Sub

    Function getDrawingList(ByRef lstDwg As List(Of String)) As Boolean
        For Each Drawing As Object In Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager
            lstDwg.Add(Drawing.name)
        Next
        If lstDwg.Count > 0 Then
            Return True
        End If
    End Function

 

 

---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 3 of 4

Anonymous
Not applicable

Hi arcticad,

 

thx for your answer, but if i do it this way, i get a  "Error 1 Option Strict On disallows late binding." Error.....

0 Likes
Message 4 of 4

Anonymous
Not applicable

i found a solution wich works fine for me! Smiley Happy

 

        For Each tDoc As Autodesk.AutoCAD.ApplicationServices.Document In Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager
            mDWGName = tDoc.Database.Filename
            If strthisDoc <> mDWGName Then cmbModelDwg.Items.Add(mDWGName)
        Next

 

0 Likes