Page 1 of 1

variable filter-list item

PostPosted: Thu Sep 20, 2018 8:04 am
by sergiowow
I actually find a block in a drawing with :

(setq ss (ssget "_X" '((2 . "blockname"))))

But I want the blockname to be a variable.

So I want to do :
(setq a "blockname") and then
(setq ss (ssget "_X" '((2 . a)))).
But this do not work. I tries : (list a), (setq a) but that doesn't work either
thanks

Re: variable filter-list item

PostPosted: Sat Sep 22, 2018 1:14 am
by pjstirling
Because you are using single-quote (') your A symbol is not being evaluated.

Try using back-quote instead:

Code: Select all
(setq ss (ssget "_X" `((2 . ,a)))).

Re: variable filter-list item

PostPosted: Sun Sep 23, 2018 8:46 am
by edgar-rft
A version without backquote would look like:
Code: Select all
(setq ss (ssget "_X" (list (cons 2 a))))

Re: variable filter-list item

PostPosted: Mon Sep 24, 2018 5:08 am
by sergiowow
Thanks Edgar, that work