PDA

View Full Version : Filtering selection sets



Coolmo
2004-08-25, 02:55 PM
I'm getting an error when trying to filter the selection set on screen. I'm using:

Dim Polyset As AcadSelectionSet
Set Polyset = ThisDrawing.SelectionSets.Add("Polyset1")
Polyset.SelectOnScreen 0, "line"

but the Polyset.SelectOnScreen 0, "line" doesn't work. Neither does:

Polyset.SelectOnScreen (0, "line") wants and = mark or something
Polyset.SelectOnScreen 0, line simply doesn't work

What am I missing? The main error states "Invalid filtertype on SelectScreen"

Ed Jobe
2004-08-25, 03:13 PM
Have you checked the help file for samples? The error says the "type" of the filter is bad. The arguments are expecting variant arrays.

Coolmo
2004-08-25, 05:08 PM
It explains the "types" as 0 for entities, 8 for layers, etc. I can't find samples from the help that show actual code, just tables for all the "types". They also list the type as 0 and not "0" and the entity as "Line" not line. I've tried all but using "0". I'll try that now.

Ed Jobe
2004-08-25, 05:28 PM
The "type" of 0 and 8 is Integer. The "type" of line is String. You need to assign the dxf code to an Integer array and the string to a variant array. Then assign the arrays to variants. Here is a sample.



Dim intFtyp(0) As Integer ' setup for the filter
Dim varFval(0) As Variant
Dim varFilter1, varFilter2 As Variant
intFtyp(0) = 0: varFval(0) = "LINE" ' get only lines
varFilter1 = intFtyp: varFilter2 = varFval

Set s1 = AddSelectionSet "ssLineFilter" ' create or get the set
s1.Clear ' clear the set
s1.SelectOnScreen varFilter1, varFilter2 ' do it
End Function

Coolmo
2004-08-25, 05:52 PM
So simply declaring the variables as integers and variants makes it work? Cool! I was just trying to enter a 0 and a "string" and hope for the best. We'll try it now. Thanks.

Ed Jobe
2004-08-25, 07:49 PM
BTW, the reason for setting it up in an array is so that you can have multiple conditions and boolean operators. The example I gave has only one condition.