Jump to content

Rotate text from angular value of polyline


darwin.ocik

Recommended Posts

Hello, 

I want to rotate text from angular value of polyline. I made a lisp here, but sometime it work, sometime it doesnt, and sometime it rotate to wrong direction. Can someone help me? Thanks

(defun c:rwq ()
(princ "\nPick text")
(setq ob (ssget '((0 . "text"))))

(princ "\nPoint ref")
(setq mid (getpoint))

(setq grs (car (entsel "\nPick pline")))
(setq engrs (entget grs))
(setq d1 (cdr (nth 15 engrs)))
(setq d2 (cdr (nth 20 engrs)))
(setq ang (angtos (angle d1 d2)))


(command-s "._rotate" ob "" mid ang)
)

 

Link to comment
Share on other sites

Something like this ?

(defun c:Test (/ s e o c a)
  ;; Tharwat - 9.7.2020	;;
  (and (setq s (car (entsel "\nPick a text to rotate : ")))
       (or (wcmatch (cdr (assoc 0 (setq e (entget s)))) "*TEXT")
           (alert "Invalid object. Try again.")
       )
       (setq s (entsel "\nPick a line or polyline segment to get angle : "))
       (or (wcmatch (cdr (assoc 0 (entget (car s)))) "LINE,*POLYLINE")
           (alert "Invalid object. Try again.")
       )
       (setq o (car s) c (vlax-curve-getclosestpointto o (cadr s))
             s (fix (vlax-curve-getparamatpoint o c))
             a (angle (vlax-curve-getpointatparam o s) (vlax-curve-getpointatparam o (1+ s)))
       )
       (entmod
         (subst (cons 50 (if (and (> a (* pi 0.5)) (< a (* pi 1.5))) (+ a pi) a))
                (assoc 50 e)
                e
         )
       )
  )
  (princ)
) (vl-load-com)

 

Link to comment
Share on other sites

Yess, like that. Thanks

But i want to select multiple text, and i want the text to rotate on specific base point.

 

Link to comment
Share on other sites

Give this a shot and let me know.

(defun c:Test (/ s e o c a)
  ;; Tharwat - 9.7.2020	;;
  (and (setq s (entsel "\nPick a line or polyline segment to get angle : "))
       (or (wcmatch (cdr (assoc 0 (entget (car s)))) "LINE,*POLYLINE")
           (alert "Invalid object. Try again.")
       )
       (setq o (car s)
             c (vlax-curve-getclosestpointto o (cadr s))
             s (fix (vlax-curve-getparamatpoint o c))
             a (angle (vlax-curve-getpointatparam o s) (vlax-curve-getpointatparam o (1+ s)))
             a (if (and (> a (* pi 0.5)) (< a (* pi 1.5))) (+ a pi) a)
       )
       (princ "\nSelect Text objects to rotate : ")
       (setq s (ssget "_:L" '((0 . "*TEXT"))))
       (setq c (getpoint "\nSpecify base point to rotate selected texts : "))
       (command "_.ROTATE" S "" "_none" c (/ (* a 180.0) pi))       
  )
  (princ)
) (vl-load-com)

 

Link to comment
Share on other sites

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...