Author Topic: LISP REQUEST/HELP  (Read 1073 times)

0 Members and 1 Guest are viewing this topic.

bery35

  • Mosquito
  • Posts: 3
LISP REQUEST/HELP
« on: June 20, 2020, 04:24:42 PM »
 I have a question. How do I select the nearest line when I click on any text. I have a code, but this code select single line. I want to select multiple text(or single text but I want to select the lines next to the text with the same content) then lisp select lines. I'm adding a video about how it works. If you help me, I will be very glad.

Code: [Select]
(defun c:sl (/ ns sc ss n m p ls) (vl-load-com)
  (if (setq ns (ssget ":s" '((0 . "text")))
        sc (ssadd) ss (ssget "x" '((0 . "line"))))
    (progn
      (repeat (setq n (sslength ss))
        (setq n (1- n) m (ssname ss n) p (cdr (assoc
          10 (entget (ssname ns 0)))) ls (cons (list
            m (distance p (vlax-curve-getclosestpointto
              (vlax-ename->vla-object m) p))) ls)))
      (sssetfirst nil (ssadd (caar (vl-sort ls
        '(lambda(a b) (< (cadr a) (cadr b))))) sc))
    )
  ) (princ)
)