KRBeckman Posted April 30, 2010 Posted April 30, 2010 Hey everybody, I need some help. I'm trying to make a simple that will add all objects on a layer specified by an entity selection to the current selection set, that way I can manipulate them all as needed. What I've got so far is: (defun c:qs () (setq obj (entsel "\nSelect object on desired layer: ")) (while (not obj) (setq obj (entsel "\nNo object selected, try again: "))) (setq ent (entget (car obj)) lay (cdr (assoc 8 ent))) (ssget "_X" '((8 . lay))) (princ (strcat "\nEverything on layer " lay " selected.")) (princ)) But I keep getting errors no matter how much I tweek it. Any help would be greatly appriciated. Quote
KRBeckman Posted April 30, 2010 Author Posted April 30, 2010 So I got it one step closer with: (defun c:qs (/ obj ent lay) (setq obj (entsel "\nSelect object on desired layer: ")) (while (not obj) (setq obj (entsel "\nNo object selected, try again: "))) (setq ent (entget (car obj)) lay (cdr (assoc 8 ent))) (ssget "_X" (list (cons 8 lay))) (princ (strcat "\nEverything on layer " lay " selected.")) (princ)) But it doesn't add everything to the current selection set, like when the grips show up. Any ideas? Quote
KRBeckman Posted April 30, 2010 Author Posted April 30, 2010 Nevermind, found this: http://www.cadtutor.net/forum/showthread.php?t=30154 And came up with this: (defun c:qs (/ obj ent lay) (setq obj (entsel "\nSelect object on desired layer: ")) (while (not obj) (setq obj (entsel "\nNo object selected, try again: "))) (setq lay (cdr (assoc 8 (entget (car obj))))) (sssetfirst nil (ssget "_X" (list (cons 8 lay)))) (princ (strcat "\nEverything on layer " lay " selected.")) (princ)) Quote
Lee Mac Posted April 30, 2010 Posted April 30, 2010 Nice one, you could shorten it to this if you wanted (defun c:qs ( / e ) (while (not (setq e (car (entsel)))) (princ "\n** Come on, you gotta do better than that **")) (sssetfirst nil (ssget "_X" (list (assoc 8 (entget e))))) (princ)) Quote
KRBeckman Posted June 17, 2010 Author Posted June 17, 2010 Any idea how I could change this so that if I already have entities selected that it will add everything on the layer of the picked object to the selection set? That way I could run this more than once and select everthing on multiple layers. Quote
alanjt Posted June 17, 2010 Posted June 17, 2010 Why not... (defun c:SA (/ pf ent ss) ;; Alan J. Thompson, 06.17.10 (setq pf (ssget "_I")) (if (and (setq ent (car (entsel "\nSelect on layer: "))) (setq ss (ssget "_X" (list (assoc 8 (entget ent)) (if (eq 2 (getvar "cvport")) (cons 410 "Model") (cons 410 (getvar "ctab")) ) ) ) ) ) ((lambda (i) (if (eq (type pf) 'PICKSET) (while (setq e (ssname pf (setq i (1+ i)))) (ssadd e ss) ) ) (sssetfirst nil ss) ) -1 ) ) (princ) ) Quote
alanjt Posted June 17, 2010 Posted June 17, 2010 works like a charm, thanks a ton You're welcome. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.