Selection set filters & Logical Operators

  • Thread starter Thread starter Tony M
  • Start date Start date
T

Tony M

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
 
an object cant possibly be on both layers at the same time
how about an 'or' instead of 'and'?
 
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
 
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
 
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,

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 said:
Tony,

I hate those operators. Just combine the objects you want and bump up the
array count.

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
 
Good point. Still dont' like those operators. ha. Actually there not that
bad
 
Thanks for all the help guys, I think you got me headed in the right
direction!!

TM
 
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
 
Back
Top