Message 1 of 12
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I'm attempting to write a text rotation routine (idea is replace "TORIENT" so that I can call the command in other routines) -
Select all text
Repeat through list
Check if upside down (radians to degrees of text rotation + rotation of UCS from WCS)
Use "textbox" to rotate 180...
it breaks here and I don't know why, any help appreciated -
(+ (RTD rotang) (ROTATION))
Full routine (probably multiple errors but haven't progressed beyond the above error).
(defun c:UPDN (/ corth sstxt num rotang angr ptxt tbox pnt1 pnt2 pnt3)
(setq corth (getvar "orthomode"))
(setq sstxt (ssget "_A" '((0 . "text")))
num -1)
(repeat (sslength sstxt)
(setq rotang (cdr (assoc 50 (entget (ssname sstxt (setq num (1+ num)))))))
(setq angr (+ (RTD rotang) (ROTATION)))
(if (and (> 90 angr) (< 270 angr))
(progn
(setq ptxt (entget (car (sstxt ssname num))))
(command "UCS" "entity" ptxt)
(setq tbox (textbox (list (car ptxt)))
pnt1 (car tbox)
pnt2 (cadr tbox)
pnt3 (polar pnt1 (angle pnt1 pnt2) (* 0.5 (distance pnt1 pnt2)
)))
(setvar "orthomode" 1)
(command "ROTATE" ptxt "" pnt3 180)
(setvar "orthomode" corth)
(command "UCS" "p")
);progn
);if
);repeat
(princ)
)
;*****************RADIANS-TO-DEGREES******************
(defun RTD (a) (* 180.0 (/ a pi)))
;************ROTATION-OF-UCS-FROM-WCS*************
(defun ROTATION (/ p1w p2w ang)
(setq p1w (trans '(0 0 0) 1 0)
p2w (trans '(10 0 0) 1 0)
ang (rtd (angle p1w p2w))
)
ang
(princ)
)
;**************************************************************
Solved! Go to Solution.