Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello friends
How can I make multiple selections and select all objects in the relevant layer?
Solved! Go to Solution.
Hello friends
How can I make multiple selections and select all objects in the relevant layer?
Solved! Go to Solution.
@k005 wrote:
Hello friends
How can I make multiple selections and select all objects in the relevant layer?
What do you mean multiple? multiple objects of the same type or one just one type of object?
This line will prompt the user to select "LWPOLYLINE" with "Drainpipe" layer on screen
(setq ss (ssget '((0 . "LWPOLYLINE")(8 . "Drainpipe"))))
This will select all "LWPOLYLINE" with "Drainpipe" layer on "Model" space without user prompt
(setq ss (ssget "_X" '((0 . "LWPOLYLINE")(8 . "Drainpipe")(410 . "Model"))))
This will select all "LWPOLYLINE" and/or "INSERT" (blocks) with "Drainpipe" layer on "Model" space without user prompt
(setq ss (ssget "_X" '((0 . "LWPOLYLINE,INSERT")(8 . "Drainpipe")(410 . "Model"))))
HTH
If you want to select objects of any type, and find all objects of any type on the Layers of those selected objects, try using LAYISO. It will turn off all the Layers other than those of the selected objects, and you should then be able to just select everything visible. LAYUNISO turns those other Layers back on.
This will be complicated by the possibility of objects on such Layers that are nested in Blocks inserted on other Layers, but I expect that will be a complication of any approach.
First of all, sorry for my late reply...
Now let me explain: The lisp code at the bottom only selects the X layer and ends.
What I want to do is select All objects belonging to both X, Y and N layers.
X Y N --» given as the symbolic layer name.
(defun C:SEL ( / e lay ss)
(setq e (nentsel "Select entity on a layer: "))
(if e (setq ss (ssget "_X" (list(cons 8 (cdr (assoc 8 (entget (car e)))))))))
(if (zerop (getvar"CMDACTIVE"))
(progn (sssetfirst ss ss)(princ"Use 'P' for this selection set: "))
)
ss
)
@k005 wrote:First of all, sorry for my late reply...
Now let me explain: The lisp code at the bottom only selects the X layer and ends.
What I want to do is select All objects belonging to both X, Y and N layers.
X Y N --» given as the symbolic layer name.
The program enables the user to select an object
(setq e (nentsel "Select entity on a layer: "))
and then proceeds to retrieve the layer of the selected entity
(cons 8 (cdr (assoc 8 (entget (car e)))))
and use the value of the layer as a filter for ssget
(setq ss (ssget "_X" (list (cons 8 (cdr (assoc 8 (entget (car e)))))) ) )
Naturally, an object can only have one layer.
Now , what we an do is to modify the code to prompt the user to continue selecting an entity in a loop, build a list of layer names, and use that for the filter.
(defun C:SEL (/ e lay ss lname layerlist) (While (setq e (nentsel "\nSelect entity on a layer: ")) (princ (strcat "\nSelected entity layer name " (setq lname (cdr (assoc 8 (entget (car e))))) ) ) (setq layerlist (cons lname layerlist)) (redraw (car e) 3) ) (setq ss (ssget "_X" (list (cons 8 (apply 'strcat (mapcar '(lambda (n) (strcat n ",")) layerlist) ) ) ) ) ) (if (zerop (getvar "CMDACTIVE")) (progn (sssetfirst ss ss) (princ "Use 'P' for this selection set: ") ) ) ss )
HTH
Hi @pbejse, your lisp works perfectly. However, would it be possible to change it to work with blocks too? I mean, when I run the lisp and click on the block in a particular layer, it wouldn't choose objects from this layer, but from layer of the nested object in block (which is in my case 0).