Populate selectionset from VB

Discussion in 'AutoCAD' started by Rikard, Mar 7, 2005.

  1. Rikard

    Rikard Guest

    Hi.
    I've got a bit of a problem, I try to make a filtered selectionset only for blocks in a drawing. But the selectionset stays empty.
    Does anyone have an idea why this code does'nt work from VB?

    Thanks in advance
    Rikard


    Private Sub Command1_Click()
    Dim acad
    Dim DataType(0) As Integer
    Dim DataValue(0) As Variant
    Dim ssSel As AcadSelectionSet
    Dim BlockRef As AcadBlockReference

    Set acad = CreateObject("AutoCad.Application")

    acad.ActiveDocument.SelectionSets.Add ("1")

    Set ssSel = acad.ActiveDocument.SelectionSets.Item("1")
    ssSel.Clear
    On Error Resume Next

    DataType(0) = 0
    DataValue(0) = "Insert"


    ssSel.Select acSelectionSetAll, , , DataType, DataValue

    For Each BlockRef In ssSel
    MsgBox BlockRef.Name
    Next

    acad.activedocument.SelectionSets.Item("1").Delete

    End Sub
     
    Rikard, Mar 7, 2005
    #1
  2. Rikard

    TomD Guest

    You might want to take a look at Peter Funk's response in the thread titled
    "HELP with Invisible BLock Supression", in the
    aec.land-desktop.customization NG. I posted a response to a question
    regarding filtering for blocks and Peter responded with an even better
    solution to accomplishing basically the same thing.
     
    TomD, Mar 7, 2005
    #2
  3. Rikard

    Rikard Guest

    Sorry my mistake.
    I used Createobject instead of getobject.

    //Rikard
     
    Rikard, Mar 7, 2005
    #3
  4. Hi Tom,

    You may care to read the other posts in response to Peter's, and the large
    number of posts in this NG on selection sets.

    I think all we can say of Peter's is that it is a reliable way of doing it.
    There are others, which in many cases are faster (if that equates to
    better).

    --


    Laurie Comerford
    CADApps
    www.cadapps.com.au
     
    Laurie Comerford, Mar 7, 2005
    #4
  5. Rikard

    TomD Guest

    I'm heading there, now.

    .........I was under the impression that the method he suggested would be
    faster..............you guys are confusing me, again!!! ;)
     
    TomD, Mar 7, 2005
    #5
  6. Rikard

    Tom Closs Guest

    Rikard,
    I don't know if you answered your problem yet but by using createobject
    instead of getobject you started a new session of AutoCAD and a blank
    drawing. Therefore there is no entities for your selection set. I hope
    this helps


    for blocks in a drawing. But the selectionset stays empty.
     
    Tom Closs, Mar 8, 2005
    #6
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.