Block listing...

Discussion in 'AutoCAD' started by cyberstrategist, Jul 16, 2004.

  1. Using VB6, I'm looking for a way to do the following:

    - Populate a ListBox with the names of the existing blocks in a drawing


    Thanks in advance!
     
    cyberstrategist, Jul 16, 2004
    #1
  2. cyberstrategist

    TomD Guest

    Block definitions or BlockReferences?
     
    TomD, Jul 16, 2004
    #2
  3. I assume that you know how set the reference to AutoCAD's type library, and
    recognize how to really get the AutoCAD application (instead of my shortcut
    way). I filtered out blocks starting with an asterisk, as those usually
    aren't ones that a user would need to deal with.

    Private Sub Form_Load()

    Dim appAcad As AcadApplication
    Set appAcad = GetObject(, "AutoCAD.Application")
    Dim ThisDrawing As AcadDocument
    Set ThisDrawing = appAcad.ActiveDocument

    Dim aBlock As AcadBlock
    Dim blkName As String
    For Each aBlock In ThisDrawing.Blocks
    blkName = aBlock.Name
    If Not blkName Like "[*]*" Then Me.List1.AddItem aBlock.Name
    Next aBlock

    Set ThisDrawing = Nothing
    Set appAcad = Nothing
    End Sub


    --
    R. Robert Bell


    Using VB6, I'm looking for a way to do the following:

    - Populate a ListBox with the names of the existing blocks in a drawing


    Thanks in advance!
     
    R. Robert Bell, Jul 17, 2004
    #3
  4. I modified / used your example here to do what I needed. Thank you. I had
    the connection in my project and used the block specific portion...

    The next task will be a bit more interesting for me but I'll try to complete
    it on my own before posting. Learning seems to be a daily thing ;-) and a
    good thing!
     
    cyberstrategist, Jul 19, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.