>>(setq LAY (cdr (assoc 8 (entget e))))
>>(ssget "_X" (list (cons 8 LAY))
>>so, how do i make the LAY variable to be useable?
You have to edit the string "[342]" this way that the result looks like "`[342`]"
So you have to write a function that check each char in your string and if it is an wildcard character,
add a "`" char to the string in front of this char.
Create the function to work with all wildcards, otherwise you will stumpled next over a layer with name "123.4"
or "wow#****" and so on.
For a very practiced one it is just a single line code,
but it is okay if you need 10 or 50 lines. Importend is just the result!
As starter for you:
(defun MyOwnQuoteStr (STR)
...
(mapcar 'chr (vl-string->list STR))
...
)
Try this: (mapcar 'chr (vl-string->list LAY))
Now, you can use FOREACH (or mapcar or whatever)
{sorry, I like to help programming, but not by publish the whole solution}