XData Filter List

XData Filter List

DGCSCAD
Collaborator Collaborator
516 Views
4 Replies
Message 1 of 5

XData Filter List

DGCSCAD
Collaborator
Collaborator

Hello all,

 

I can't figure this one out:

 

Given:

test_XD = "12345"

 

Why does this work...

(setq test_SS (ssget "X" '((0 . "INSERT") (-3 ("12345")) (410 . "~Model"))))

<selection set: ###>

 

...but this does not?

(setq test_SS (ssget "X" '((0 . "INSERT") (-3 (test_XD)) (410 . "~Model"))))

Error: bad SSGET list value

 

 

AutoCad 2018 (full)
Win 11 Pro
0 Likes
Accepted solutions (1)
517 Views
4 Replies
Replies (4)
Message 2 of 5

komondormrex
Mentor
Mentor
Accepted solution

because you cannot quote lisp expressions.

try this

(setq test_SS (ssget "X" (list '(0 . "INSERT") (list -3 (list test_XD)) '(410 . "~Model"))))

 

0 Likes
Message 3 of 5

DGCSCAD
Collaborator
Collaborator

Thank you!

 

I had just figured it out and came back to post:

 

(setq test_SS (ssget "X" (list '(0 . "INSERT") '(410 . "~Model") (cons -3 (list (list test_XD))))))

 

Much obliged Komondormrex.

 

I had a bit of a brain cramp on that one. lol

AutoCad 2018 (full)
Win 11 Pro
0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant

To elaborate a little:

 

A "quoted list" [your (ssget) filter list with the apostrophe ' at the beginning] cannot contain anything that needs to be evaluated, but everything in it must be taken literally.  Your test_XD is a variable that would require evaluation, so if that is to be in there, you must use the explicit (list) function, not the quoted-list '( shortcut.  Note in @komondormrex's suggestion that within that (list) function, some of the sub-lists can still be quoted lists -- it's just the one involving the evaluation of a variable that can't be.

 

Read about the (list) and (quote) functions in the AutoLisp Reference for more detailed understanding.

Kent Cooper, AIA
Message 5 of 5

DGCSCAD
Collaborator
Collaborator

Thank you Mr C, will do.

 

I had known this but it escaped me for some reason.

 

Imagine my brain as a shot glass, and LISP as a gallon water. If you pour a gallon of water into a shot glass, some of it's gonna spill over the sides.

 

All kidding aside, thank you both for the help. It's always appreciated.

AutoCad 2018 (full)
Win 11 Pro
0 Likes