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

documentcollection ??

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
417 Views, 3 Replies

documentcollection ??

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

3 REPLIES 3
Message 2 of 4
arcticad
in reply to: Anonymous

 

    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))
Message 3 of 4
Anonymous
in reply to: arcticad

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.....

Message 4 of 4
Anonymous
in reply to: Anonymous

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

 

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost