nano Posted March 19, 2019 Share Posted March 19, 2019 Hello, I would like to know if it is possible in lisp assign to polyline and lines the layer of the nearest texts? thanks Quote Link to comment Share on other sites More sharing options...
Emmanuel Delay Posted March 21, 2019 Share Posted March 21, 2019 (vl-load-com) ;; ALNT (for Assign Lines Nearest Text) (defun c:ALNT ( / ss i pt1 pt2 dst lines texts ent tp l txt ind) (setq ss (ssget (list (cons 0 "TEXT,LINE,LWPOLYLINE,POLYLINE") ) )) (setq lines (list) texts (list) ) (setq i 0) (repeat (sslength ss) (setq ent (ssname ss i )) (setq tp (cdr (assoc 0 (entget ent)))) (cond ((= tp "TEXT") (setq texts (append texts (list ent))) ) ( (or (= tp "LINE") (= tp "LWPOLYLINE") (= tp "POLYLINE")) (setq lines (append lines (list ent))) ) ) (setq i (+ i 1)) ) (foreach l lines (setq pt1 (cdr (assoc 10 (entget l)))) (setq i 0 dst nil ) (foreach txt texts (setq pt2 (cdr (assoc 10 (entget txt)))) (if (or (= dst nil) (< (distance pt1 pt2) dst) ) (progn (setq dst (distance pt1 pt2)) (setq ind i) )) (setq i (+ i 1)) ) (vla-put-layer (vlax-ename->vla-object l) (vla-get-layer (vlax-ename->vla-object (nth ind texts))) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
nano Posted March 22, 2019 Author Share Posted March 22, 2019 thank you very much for your help I will try it regards Quote Link to comment Share on other sites More sharing options...
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.