Why I don´t get objects in the selectionset with AddItems method?

Discussion in 'AutoCAD' started by Hartmut Callies, Aug 21, 2003.

  1. Hallo,
    I have a acad 2000-drawing with some blocks. In the block are a circle
    and three attributes.
    Now I must insert the tree atrributes and the circle in a selectionset.
    But I don`t get the objects in the selectionset. In the array
    "objAttributesArray" are all objects!
    What is not correct with: SSetAuto.AddItems objAttributesArray ?
    Who can help me with a idea?


    Thanks
    Hartmut Callies


    sub test ()
    Dim SSetUser As AcadSelectionSet
    Dim SSetAuto As AcadSelectionSet
    Dim objectInSSetUser As AcadEntity
    Dim i As Integer
    Dim objBlockRef As AcadBlockReference
    Dim objBlock As AcadBlock
    Dim objectInBlock As AcadEntity
    Dim objAttributesArray(0 To 3) As AcadEntity

    ' On Error Resume Next

    '//first selectionset is for the user
    Set SSetUser = ThisDrawing.SelectionSets("SSET1")
    If Err Then
    Err.Clear
    Set SSetUser = ThisDrawing.SelectionSets.Add("SSET1")
    End If

    SSetUser.Clear

    SSetUser.SelectOnScreen '//User

    '//second selectionset for the program
    Set SSetAuto = ThisDrawing.SelectionSets("SSET2")
    If Err Then
    Err.Clear
    Set SSetAuto = ThisDrawing.SelectionSets.Add("SSET2")
    End If

    SSetAuto.Clear

    For Each objectInSSetUser In SSetUser
    Select Case objectInSSetUser.ObjectName
    Case "AcDbBlockReference" '//<<<--- BLOCK
    Set objBlockRef = objectInSSetUser
    i = 0
    Set objBlock = ThisDrawing.Blocks(objBlockRef.name)
    For Each objectInBlock In objBlock
    Set objAttributesArray(i) = objectInBlock
    i = i + 1
    Next objectInBlock
    End Select
    Next objectInSSetUser

    For i = LBound(objAttributesArray) To UBound(objAttributesArray)
    Debug.Print "test1 : " & objAttributesArray(i).ObjectName
    Next i

    SSetAuto.AddItems objAttributesArray '<<<<<<<<<<<
    error

    For i = 0 To SSetAuto.Count
    Debug.Print "test2 : " & SSetAuto(i).ObjectName
    Next i
    end sub
     
    Hartmut Callies, Aug 21, 2003
    #1
  2. I'm sure we have told you before that you *cannot* place objects from a
    Block object into a selection set.

    http://tinyurl.com/kqeq


    --
    R. Robert Bell, MCSE
    www.AcadX.com


    | Hallo,
    | I have a acad 2000-drawing with some blocks. In the block are a circle
    | and three attributes.
    | Now I must insert the tree atrributes and the circle in a selectionset.
    | But I don`t get the objects in the selectionset. In the array
    | "objAttributesArray" are all objects!
    | What is not correct with: SSetAuto.AddItems objAttributesArray ?
    | Who can help me with a idea?
    |
    |
    | Thanks
    | Hartmut Callies
    |
    |
    | sub test ()
    | Dim SSetUser As AcadSelectionSet
    | Dim SSetAuto As AcadSelectionSet
    | Dim objectInSSetUser As AcadEntity
    | Dim i As Integer
    | Dim objBlockRef As AcadBlockReference
    | Dim objBlock As AcadBlock
    | Dim objectInBlock As AcadEntity
    | Dim objAttributesArray(0 To 3) As AcadEntity
    |
    | ' On Error Resume Next
    |
    | '//first selectionset is for the user
    | Set SSetUser = ThisDrawing.SelectionSets("SSET1")
    | If Err Then
    | Err.Clear
    | Set SSetUser = ThisDrawing.SelectionSets.Add("SSET1")
    | End If
    |
    | SSetUser.Clear
    |
    | SSetUser.SelectOnScreen '//User
    |
    | '//second selectionset for the program
    | Set SSetAuto = ThisDrawing.SelectionSets("SSET2")
    | If Err Then
    | Err.Clear
    | Set SSetAuto = ThisDrawing.SelectionSets.Add("SSET2")
    | End If
    |
    | SSetAuto.Clear
    |
    | For Each objectInSSetUser In SSetUser
    | Select Case objectInSSetUser.ObjectName
    | Case "AcDbBlockReference" '//<<<--- BLOCK
    | Set objBlockRef = objectInSSetUser
    | i = 0
    | Set objBlock = ThisDrawing.Blocks(objBlockRef.name)
    | For Each objectInBlock In objBlock
    | Set objAttributesArray(i) = objectInBlock
    | i = i + 1
    | Next objectInBlock
    | End Select
    | Next objectInSSetUser
    |
    | For i = LBound(objAttributesArray) To UBound(objAttributesArray)
    | Debug.Print "test1 : " & objAttributesArray(i).ObjectName
    | Next i
    |
    | SSetAuto.AddItems objAttributesArray
    '<<<<<<<<<<<
    | error
    |
    | For i = 0 To SSetAuto.Count
    | Debug.Print "test2 : " & SSetAuto(i).ObjectName
    | Next i
    | end sub
    |
    |
     
    R. Robert Bell, Aug 21, 2003
    #2
  3. Hartmut Callies

    joesu Guest

    Hartmut,

    Perhaps a better way to approach a solution would be to ask "What are you attempting to accomplish?" There may actually be another to accomplish what you want if I knew exactly what you are looking for as a result.

    Joe
    --
     
    joesu, Aug 21, 2003
    #3
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.