darwin.ocik Posted July 9, 2020 Posted July 9, 2020 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) ) Quote
Tharwat Posted July 9, 2020 Posted July 9, 2020 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) Quote
lrm Posted July 9, 2020 Posted July 9, 2020 Not as slick as @Tharwat's code you can also use the align command with a couple of screen picks. 1 Quote
darwin.ocik Posted July 9, 2020 Author Posted July 9, 2020 Yess, like that. Thanks But i want to select multiple text, and i want the text to rotate on specific base point. Quote
Tharwat Posted July 9, 2020 Posted July 9, 2020 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) Quote
darwin.ocik Posted July 9, 2020 Author Posted July 9, 2020 Yess. Exactly what i need. Thanks Th 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.