Selection set filters & Logical Operators

Discussion in 'AutoCAD' started by Tony M, Jun 15, 2004.

  1. Tony M

    Tony M Guest

    Hi All,

    LISP guy here trying to learn VBA. Can anyone please tell me why this
    bit of code won't work. My selection set comes up empty. I am trying to
    select all objects in a drawing that are on 2 specific layers.

    Thanks in advance
    Tony M.

    Private Sub Test()

    Dim sscoords As AcadSelectionSet
    Dim FilterType(3) As Integer
    Dim FilterData(3) As Variant


    Set sscoords = ThisDrawing.SelectionSets.Add("SS1")

    FilterType(0) = -4
    FilterData(0) = "<AND"
    FilterType(1) = 8
    FilterData(1) = "Layer-1
    FilterType(2) = 8
    FilterData(2) = "Layer-2"
    FilterType(3) = -4
    FilterData(3) = "AND>"

    sscoords.Select acSelectionSetAll, , , FilterType, FilterData


    End Sub
     
    Tony M, Jun 15, 2004
    #1
  2. Tony M

    MP Guest

    an object cant possibly be on both layers at the same time
    how about an 'or' instead of 'and'?
     
    MP, Jun 15, 2004
    #2
  3. Hey Tony,
    I use this method. Paul

    Public Sub ssTest()
    Dim ssTest As AcadSelectionSet
    Dim gpCode() As Integer
    Dim gpData As Variant

    With ThisDrawing.Utility
    Set ssTest = ThisDrawing.SelectionSets.Add("ss1")

    ReDim gpCode(0): ReDim gpData(0)
    gpCode(0) = 8: gpData(0) = "Layer-1,Layer-2"

    ssTest.Select acSelectionSetAll, , , gpCode, gpData
    End With
    End Sub
     
    Paul Richardson, Jun 15, 2004
    #3
  4. Tony, Made sense to me.

    Paul

    Public Sub AllBut()
    Dim ssTest As AcadSelectionSet
    Dim gpCode() As Integer
    Dim gpData As Variant

    With ThisDrawing.Utility
    Set ssTest = ThisDrawing.SelectionSets.Add("ssAllBut")

    ReDim gpCode(0): ReDim gpData(0)
    gpCode(0) = 8: gpData(0) = "Layer1,Layer2"

    ssTest.Select acSelectionSetAll, , , gpCode, gpData
    End With
    End Sub
     
    Paul Richardson, Jun 15, 2004
    #4
  5. Tony M

    Tony M Guest

    Thanks for the reply.

    Basically I'm searching for 2 different type of objects which are on
    different layers. Am I going about this wrong? Do I need to create 2
    different selection sets??

    TM
     
    Tony M, Jun 15, 2004
    #5
  6. Tony M

    Tony M Guest

    I just tried "OR" with the same "Empty" results.
    ??
     
    Tony M, Jun 15, 2004
    #6
  7. Tony M

    Tony M Guest

    Paul,

    That worked great. Thanks alot!!

    Tony M
     
    Tony M, Jun 15, 2004
    #7
  8. Tony M

    Tony M Guest

    Paul,

    That worked great. Thanks alot!!

    Tony M
     
    Tony M, Jun 15, 2004
    #8
  9. Tony,

    I hate those operators. Just combine the objects you want and bump up the
    array count.
    See my post in Subject: Re: Selection set of everything except...

    ReDim gpCode(1): ReDim gpData(1)
    gpCode(0) = 0: gpData(0) = "Line,Circle"
    gpCode(0) = 8: gpData(0) = "Layer1,Layer2"

    This will select all lines and circles on layer1 & layer2

    Paul
     
    Paul Richardson, Jun 15, 2004
    #9
  10. There is a limit to the length of the string that you
    can pass in a filter list. Logical operators allow you
    to have any number of items, regardless of the total
    length of all the strings.



    AutoCAD based Security Planning Solutions:
    http://www.caddzone.com/securityplanning
     
    Tony Tanzillo, Jun 16, 2004
    #10
  11. Good point. Still dont' like those operators. ha. Actually there not that
    bad
     
    Paul Richardson, Jun 16, 2004
    #11
  12. Tony M

    Tony M Guest

    Thanks for all the help guys, I think you got me headed in the right
    direction!!

    TM
     
    Tony M, Jun 16, 2004
    #12
  13. Hi Paul
    I am probably off the mark but I think you are saying MP's logic is incorrect. MP's response is a correct response to why Tony's code didn't work. In your code which I agree is simpler the "," acts as an OR.
    Regards - Nathan
     
    Nathan Taylor, Jun 28, 2004
    #13
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.