Skip overlapping objects in entsel selection

Skip overlapping objects in entsel selection

carlos_m_gil_p
Advocate Advocate
561 Views
8 Replies
Message 1 of 9

Skip overlapping objects in entsel selection

carlos_m_gil_p
Advocate
Advocate

Hi guys, how have you been?
I wanted to ask you a question about the entsel function.
Is there a way to skip overlapping objects when selecting with the entsel function?
For example, I need to select a line, but there are other objects on the line.
I once saw that it was possible, but now that I need it, I don't know how to do it.
I would appreciate any help you can give me.
I am attaching a dwg where I am testing it, it contains a mesh and on the edges of the mesh there are lines, but there is the mesh and a 3d polyline superimposed on it.

 

(defun c:xxx (/ e) 
  ; Selection
  (if (setq e (entget (car (entsel "\nSelect Line: ")))) 
    (if (= "LINE" (cdr (assoc 0 e))) 
      (princ "\n Selected Line")
      (princ "\n Invalid object")))
  ;
  (princ)
  ;
)

 

 


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes
562 Views
8 Replies
Replies (8)
Message 2 of 9

marko_ribar
Advisor
Advisor

Perhaps like this :

 

(defun c:xxx ( / e )
  (prompt "\nPick Line: ")
  (if (setq e (ssget "_.+:S:E" (list (cons 0 "LINE"))))
    (progn
      (setq e (ssname e 0)) ;;; e - ename (LINE enitity)
      ;;; do other stuff with e - LINE ;;;
    )
    (prompt "\nMissed... Better luck next time...")
  )
  (princ)
)

 

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 3 of 9

Kent1Cooper
Consultant
Consultant

Can't you just use the selector to pin down which of the objects you want?  That still works within an (entsel) function:

Kent1Cooper_0-1727455898537.png

Kent Cooper, AIA
Message 4 of 9

paullimapa
Mentor
Mentor

little adjustment...need to change this line:

(ssget "_.+:S:E" (list (cons 0 "LINE")))

to this line:

(ssget "_+.:E:S" (list (cons 0 "LINE")))

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 5 of 9

carlos_m_gil_p
Advocate
Advocate

Hi guys.
Thanks a lot for your help.
I had seen that it worked with ssget.
But I was wondering if it could be done with entsel, because I have almost all my routines with entsel.


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes
Message 6 of 9

paullimapa
Mentor
Mentor

unfortunately entsel has no filtering option which is why ssget is the way to go


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 7 of 9

carlos_m_gil_p
Advocate
Advocate

Hello, how are you?
I thought it could be done with Entsel.
Many thanks to everyone for their collaboration and help.
Greetings to all.


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes
Message 8 of 9

john.uhden
Mentor
Mentor

@carlos_m_gil_p ,

Another way to look at is:

  1. Set an Undo Mark.
  2. Set a filter to select only the type of entity you want
      (setq ss (ssget "x" (setq filter '((0 . "LINE")))))
  3. Use Draworder to bring SS lines to the front.
  4. Now use your entsel which should find the object in front rather than in the back.
  5. Use Undo Back to restore the draworder.
  6. Proceed with the rest of your code.

 

John F. Uhden

Message 9 of 9

carlos_m_gil_p
Advocate
Advocate

Thanks bro, I'll try it.


AutoCAD 2026
Visual Studio Code 1.99.3
AutoCAD AutoLISP Extension 1.6.3
Windows 10 (64 bits)

0 Likes