asdfgh Posted September 6, 2022 Posted September 6, 2022 Hii Everyone, I want a lisp to move all mtexts to nearest polyline ends. DWG sample is attached. new block3.dwg Thanks in Advance Quote
Tharwat Posted September 6, 2022 Posted September 6, 2022 (defun c:test (/ int sel ent get pos pts ins srt) ;;----------------------------------------------------;; ;; Author : Tharwat Al Choufi ;; ;; website: https://autolispprograms.wordpress.com ;; ;;----------------------------------------------------;; (and (princ "\nSelect Polylines & Texts : ") (setq int -1 sel (ssget "_:L" '((0 . "*TEXT,LWPOLYLINE"))) ) (while (setq int (1+ int) ent (ssname sel int) ) (setq get (entget ent) pos (cdr (assoc 10 get)) ) (or (and (= (cdr (assoc 0 get)) "LWPOLYLINE") (setq pts (cons pos pts) pts (cons (cdr (assoc 10 (reverse get))) pts) ) ) (setq ins (cons (list pos ent) ins)) ) ) (while (and ins pts) (and (setq pos (car ins)) (setq srt (car (vl-sort pts (function (lambda (j k) (< (distance (car pos) j) (distance (car pos) k)) ) ) ) ) pts (vl-remove srt pts) ) (vlax-invoke (vlax-ename->vla-object (cadr pos)) 'Move (car pos) (append srt '(0.0)) ) ) (setq ins (cdr ins)) ) ) (princ) ) (vl-load-com) 1 Quote
asdfgh Posted September 7, 2022 Author Posted September 7, 2022 Thank you so much for your reply, it works brilliantly. Can same type of lisp work on block ? You can find it in the attached drawingnew block3.dwg Quote
Tharwat Posted September 7, 2022 Posted September 7, 2022 You're welcome. Just add the entity name to the selection set as follows. (0 . "*TEXT,INSERT,LWPOLYLINE") 2 Quote
asdfgh Posted September 8, 2022 Author Posted September 8, 2022 Than you so much for your help 1 Quote
Engineer_Yasser Posted September 27, 2023 Posted September 27, 2023 (edited) On 9/6/2022 at 6:46 PM, Tharwat said: (defun c:test (/ int sel ent get pos pts ins srt) ;;----------------------------------------------------;; ;; Author : Tharwat Al Choufi ;; ;; website: https://autolispprograms.wordpress.com ;; ;;----------------------------------------------------;; (and (princ "\nSelect Polylines & Texts : ") (setq int -1 sel (ssget "_:L" '((0 . "*TEXT,LWPOLYLINE"))) ) (while (setq int (1+ int) ent (ssname sel int) ) (setq get (entget ent) pos (cdr (assoc 10 get)) ) (or (and (= (cdr (assoc 0 get)) "LWPOLYLINE") (setq pts (cons pos pts) pts (cons (cdr (assoc 10 (reverse get))) pts) ) ) (setq ins (cons (list pos ent) ins)) ) ) (while (and ins pts) (and (setq pos (car ins)) (setq srt (car (vl-sort pts (function (lambda (j k) (< (distance (car pos) j) (distance (car pos) k)) ) ) ) ) pts (vl-remove srt pts) ) (vlax-invoke (vlax-ename->vla-object (cadr pos)) 'Move (car pos) (append srt '(0.0)) ) ) (setq ins (cdr ins)) ) ) (princ) ) (vl-load-com) Please , How to Select All Polylines in the drawing except from Frozen and Locked and OFF layers ? Edited September 27, 2023 by Engineer_Yasser Quote
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.