Message 1 of 5

Not applicable
12-01-2015
08:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have created a lisp that selects entities or objects on a certain layer.
It worked great until I added the option 'Pick-Layer'. I cannot for the life of me input to a variable the coorect format list for the filter. It should return something like:
((8. "LAYER1"))
With double parentheses at each end.
But the best I can get it to do is:
(8 . "LAYER1")
(single parentheses )
I've tried several ways, but the code fails when it tries to read the variable (lay) with the picked layer .
(defun c:Select_Items ( / ent filt lay optn sset) (initget "Text Attributes Blocks Lines PLines Pick-Layer Layer-Dimensions Layer-No-Print Layer-Screen Layer-Text") (setq optn (cond ((getkword "\n [Text/Attributes/Blocks/Lines/PLines/Layer-Dimensions/Pick-Layer/Layer-No-Print/Layer-Screen/Layer-Text] <Text>")) ("Text"))) (cond ((equal optn "Attributes") (setq filt '((0 . "ATTDEF"))) ) ((equal optn "Blocks") (setq filt '((0 . "INSERT"))) ) ((equal optn "Lines") (setq filt '((0 . "LINE"))) ) ((equal optn "PLines") (setq filt '((0 . "LWPOLYLINE"))) ) ((equal optn "Text") (setq filt '((0 . "*TEXT"))) ) ((equal optn "Pick-Layer") (setq ent (car (entsel "\nSelect object to choose layer: "))) (setq lay (cdr(assoc 8 (entget ent)))) (setq filt '((8 . lay))) ;(setq optn (strcat "Layer " lay)) ) ((equal optn "Layer-Dimensions") (setq filt '((8 . "DIMENSIONS"))) ) ((equal optn "Layer-Screen") (setq filt '((8 . "SCREEN"))) ) ((equal optn "Layer-No-Print") (setq filt '((8 . "NO PRINT"))) ) ((equal optn "Layer-Text") (setq filt '((8 . "TEXT"))) ) );; end cond (sssetfirst nil (setq sset (ssget filt))) (if sset (princ (strcat "\n "(itoa (sslength sset)) " "optn" Items Selected")) (princ (strcat "\n No " optn " Selected")) ) (princ) )
The code works fine using all the other options except that one
Solved! Go to Solution.