Guest Posted December 6, 2022 Posted December 6, 2022 Hi i am using this code to center text to Lines. I am trying to update the code to support for Mtext but is not working.Can any one help? (defun c:Atcl (/ l ss i sn v p e) (vl-load-com) ;;; Tharwat 31. May. 2012 ;;; (if (and (setq l (car (entsel "\n Επιλέξτε Line :"))) (eq (cdr (assoc 0 (entget l))) "LINE") (progn (prompt "Επιλέξτε Text για μετακίνηση στην επιλεγμένη line") (setq ss (ssget "_:L" '((0 . "TEXT,MTEXT")))) ) ) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (setq v (vlax-ename->vla-object sn)) (setq p (vlax-curve-getclosestpointto l (cdr (assoc 10 (entget sn))) ) ) (if (eq (cdr (assoc 0 (setq e (entget sn)))) "TEXT,MTEXT") (progn (entmod (subst (cons 71 5) (assoc 71 e) e)) (vla-put-insertionpoint v (vlax-3d-point p)) ) (progn ;(vla-put-alignment v acAlignmentTopCenter) (vla-put-alignment v acAlignmentMiddleCenter) (vla-put-TextAlignmentPoint v (vlax-3D-point p)) ) ) ) ) (princ) ) Thanks Quote
robierzo Posted December 6, 2022 Posted December 6, 2022 Replace (if (eq (cdr (assoc 0 (setq e (entget sn)))) "TEXT,MTEXT") with (if (or (eq (cdr (assoc 0 (setq e (entget sn)))) "TEXT") (eq (cdr (assoc 0 (setq e (entget sn)))) "MTEXT")) 2 Quote
pkenewell Posted December 6, 2022 Posted December 6, 2022 4 hours ago, robierzo said: Replace (if (eq (cdr (assoc 0 (setq e (entget sn)))) "TEXT,MTEXT") with (if (or (eq (cdr (assoc 0 (setq e (entget sn)))) "TEXT") (eq (cdr (assoc 0 (setq e (entget sn)))) "MTEXT")) You could also go with: (if (wcmatch (cdr (assoc 0 (setq e (entget sn)))) "TEXT,MTEXT") 2 Quote
Steven P Posted December 6, 2022 Posted December 6, 2022 without checking , does wcmatch accept wildcards, * ? .... "*TEXT") 1 Quote
pkenewell Posted December 6, 2022 Posted December 6, 2022 1 minute ago, Steven P said: without checking , does wcmatch accept wildcards, * ? .... "*TEXT") Yes. But there might be other types of text, such as ARCTEXT (or was it RTEXT? Can't remember LOL). 2 Quote
dexus Posted December 7, 2022 Posted December 7, 2022 Or using member: (if (member (cdr (assoc 0 (setq e (entget sn)))) '("MTEXT" "TEXT")) 2 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.