Author Topic: Select Highlight everything on a layer  (Read 240 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Water Moccasin
  • Posts: 2076
  • I can't remeber what I already asked! I need help!
Select Highlight everything on a layer
« on: July 17, 2017, 12:06:03 pm »
The lisp below does most of what I need it to do. Basically "for me" its similar to layerisolate. I then select all on the screen.

Code: [Select]
(defun C:SELECTLAYER ( / e lay)
 (setq e (nentsel "Select entity on a layer: "))
 (if e (ssget "_X" (list(cons 8 (cdr(assoc 8 (entget(car e))))))))
 (command "_select" "previous")
)
(C:SELECTLAYER)

I can usually run the routine but hit cancel, type in select previous and I get the result I am looking for. Am I missing another line? Thanks!!!
Autodesk Infrastructure Design Suite 2017

ronjonp

  • Needs a day job
  • Posts: 6403
Re: Select Highlight everything on a layer
« Reply #1 on: July 17, 2017, 12:18:46 pm »
Maybe this?

Code - Auto/Visual Lisp: [Select]
  1. (defun c:selectlayer (/ e )
  2.  (if (setq e (nentsel "Select entity on a layer: "))
  3.    (sssetfirst nil (ssget "_X" (list (assoc 8 (entget (car e))))))
  4.  )
  5.  (princ)
  6. )
« Last Edit: July 17, 2017, 12:26:53 pm by ronjonp »

Windows 10 x64 - AutoCAD /C3D 2018

Custom Build PC

MSTG007

  • Water Moccasin
  • Posts: 2076
  • I can't remeber what I already asked! I need help!
Re: Select Highlight everything on a layer
« Reply #2 on: July 17, 2017, 12:22:31 pm »
Sometimes, ( I wanna smack myself in the head ). Thanks for the save again!
Autodesk Infrastructure Design Suite 2017

gile

  • Water Moccasin
  • Posts: 2089
  • Marseille, France
Re: Select Highlight everything on a layer
« Reply #3 on: July 17, 2017, 12:31:16 pm »
Hi

Here's a way which honors pickfirst and can also be used within a "Select object" prompt (entering (ssl) expression).

Code - Auto/Visual Lisp: [Select]
  1. (defun ssl (/ ss ent)
  2.  (if
  3.    (or
  4.      (and
  5. (setq ss (cadr (ssgetfirst)))
  6. (= 1 (sslength ss))
  7. (setq ent (ssname ss 0))
  8.      )
  9.      (and
  10. (sssetfirst nil nil)
  11. (setq ent (car (entsel)))
  12.      )
  13.    )
  14.    (ssget "_X" (list (assoc 8 (entget ent))))
  15.  )
  16. )
  17.  
  18. (defun c:ssl (/)
  19.  (sssetfirst nil (ssl))
  20.  (princ)
  21. )
Speaking English as a French Frog

MSTG007

  • Water Moccasin
  • Posts: 2076
  • I can't remeber what I already asked! I need help!
Re: Select Highlight everything on a layer
« Reply #4 on: July 17, 2017, 12:33:25 pm »
Neat... Thank you for sharing!
Autodesk Infrastructure Design Suite 2017

Grrr1337

  • Bull Frog
  • Posts: 417
Re: Select Highlight everything on a layer
« Reply #5 on: July 17, 2017, 04:14:18 pm »
This works the same as ronjonp's [ if not worse ] :

Code - Auto/Visual Lisp: [Select]
  1. (defun C:test ( / r )
  2.  (vl-every '(lambda (x) (eval x))
  3.    '(
  4.      (setq r (nentsel "Select entity on a layer: "))
  5.      (setq r (entget (car r)))
  6.      (setq r (assoc 8 r))
  7.      (setq r (ssget "_X" (list r)))
  8.      (sssetfirst nil r)
  9.    )
  10.  )
  11.  (princ)
  12. )

I'm just playin around and practice.

Lee Mac

  • Seagull
  • Posts: 11836
  • AutoCAD 2015 Windows 7 London, England
Re: Select Highlight everything on a layer
« Reply #6 on: July 17, 2017, 04:52:04 pm »
FWIW, '(lambda (x) (eval x)) could be 'eval

Grrr1337

  • Bull Frog
  • Posts: 417
Re: Select Highlight everything on a layer
« Reply #7 on: July 17, 2017, 04:59:36 pm »
FWIW, '(lambda (x) (eval x)) could be 'eval

Duhh!
Thanks, Lee! :)