Block in SSGet

Block in SSGet

rvtquestions
Advocate Advocate
4,086 Views
3 Replies
Message 1 of 4

Block in SSGet

rvtquestions
Advocate
Advocate

My intention is: user prompt pick block and that would inform an ssget filter. I am aware of this line of code:

 

ssget "_x" '((0 . "INSERT")(2 . "Blockname")))

 

however from my use of it, you have to manually type in the blockname and cannot reference a variable for example

 

 

(setq pt(cadr(entsel"\nSelect Block:")))
(setq e1(ssget pt))
(setq e2 (entget (ssname e1 0)))
(setq bname (cdr(assoc 2 e2)))

ssget "_x" '((0 . "INSERT")(2 . bname)))

 

Am I missing something fundamentally simple or can this not be done? I keep resulting in an error. Any help would be appreciated. Thank you!

Accepted solutions (1)
4,087 Views
3 Replies
Replies (3)
Message 2 of 4

ВeekeeCZ
Consultant
Consultant
Accepted solution

' will not evaluate an expression. So use (list) and (cons) functions...

(ssget "_x" (list '(0 . "INSERT") (cons 2 bname)))

 

Added: actually if you scroll down the page you can find THIS THREAD where is this approach used many times....

Message 3 of 4

Shneuph
Collaborator
Collaborator

Yes. It's the '( again.

 

(ssget "_x" (list '(0 . "INSERT") (cons 2 bname)))

 

http://www.lee-mac.com/quote.html

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
0 Likes
Message 4 of 4

ВeekeeCZ
Consultant
Consultant

BTW Seeing the rest of the code... (ssget pt) You've got a kudos for that... I never know that's possible...

 

Usually the code would look like this...

 

(if (setq ensel (entsel "\nSelect Block: "))
  (setq bname (cdr (assoc 2 (entget (car ensel))))))
0 Likes