Jump to content

Recommended Posts

Posted

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

Posted

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"))

 

  • Like 2
Posted
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")
  • Like 2
Posted

without checking , does wcmatch accept wildcards, * ?

 

.... "*TEXT")

  • Like 1
Posted
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).

  • Like 2
Posted

Or using member:

(if (member (cdr (assoc 0 (setq e (entget sn)))) '("MTEXT" "TEXT"))
  • Like 2

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...