Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CONS question

3 REPLIES 3
Reply
Message 1 of 4
richie_hodgson
364 Views, 3 Replies

CONS question

I would like to do something like

 

(if (setq SS (ssget "X" (list (cons 0 "INSERT") (cons 2 "TOBY") (cons 2 "MANI"))))        )

 

where the selection set SS includes any instance of the block "TOBY" and "MANI"

 

my code isn't working where am I going wrong? 

Richie
3 REPLIES 3
Message 2 of 4
dbroad
in reply to: richie_hodgson

This should work (untested)

 

(ssget "x" '((0 . "insert")(2 . "TOBY,MANI")))

 

not including the if and setq.

 

Wildcards are also supported (if I remember correctly).  There is no need to use CONS unless you have a symbol that needs to be evaluated.

Architect, Registered NC, VA, SC, & GA.
Message 3 of 4
richie_hodgson
in reply to: dbroad

Marvelous, will remember that one for next time.

Richie
Message 4 of 4
Lee_Mac
in reply to: richie_hodgson

Hi Richie,

 

The reason that your original code does not work is because the ssget filter list employs an implicit AND operator when evaluating each item to return a match.

 

Hence, in your code, the selection was attempting to find an INSERT entity with DXF group 2 (block name) containing the value TOBY and containing the value MANI - this is of course impossible since DXF group 2 can only hold one of these values.

 

In the code supplied by dbroad, the ssget fitler list is using a wildcard pattern to match either TOBY or MANI as the value of DXF group 2. This is possible where string valued groups are concerned as ssget will permit the use of wildcards; for groups using different data types (such as DXF group 40, for example), logical operators (such as '(-4 . "<OR") (-4 . "OR>") can be used - my ssget function reference provides some examples of these.

 

Lee

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost