leonucadomi Posted March 10 Posted March 10 hello all: I use a code that aligns a text with a line The problem is that sometimes I need to rotate the text 180 degrees I would like to modify this routine so that when you rotate the text you have the option to rotate it 180 or exit if it is the correct angle here code. defun c:TY (/) (setq old_err *error*) (defun *error* (a /) (princ "") (setq *error* old_err) (princ) ) (setvar "cmdecho" 0) (vl-load-com) (setq VlaObjLine (vlax-ename->vla-object (car (entsel "Selecciona una linea : ")) ) ) (setq LinAngle (vla-get-Angle VlaObjLine)) (while (setq VlaObjText (vlax-ename->vla-object (car (entsel "Selecciona un texto : ")) ) ) (vla-put-Rotation VlaObjText LinAngle) (vlax-release-object VlaObjText) ) (vlax-release-object VlaObjLine) (setvar "cmdecho" 1) (princ) );fin defun thanks Quote
GLAVCVS Posted March 10 Posted March 10 Hi Maybe it's better to solve the problem from scratch. Below '(setq LinAngle...)' write: (if (and (< LinAngle 4.71239) (> LinAngle 1.5708)) (setq LinAngle (+ LinAngle PI)) ) Quote
GLAVCVS Posted March 10 Posted March 10 Note: It doesn't matter if 'LinAngle' exceeds 2PI, AutoCAD takes care of subtracting the excess 1 Quote
GLAVCVS Posted March 10 Posted March 10 (edited) But if for some reason you want to keep the current behavior and change the orientation at the end, the code could be like this: (defun c:TY (/) (setq old_err *error*) (defun *error* (a /) (princ "") (setq *error* old_err) (princ) ) (setvar "cmdecho" 0) (vl-load-com) (setq VlaObjLine (vlax-ename->vla-object (car (entsel "Selecciona una linea : ")) ) ) (setq LinAngle (vla-get-Angle VlaObjLine)) ;;; (if (and (< LinAngle 4.71239) (> LinAngle 1.5708)) ;;; (setq LinAngle (+ LinAngle PI)) ;;; ) (while (setq VlaObjText (vlax-ename->vla-object (car (entsel "Selecciona un texto : ")) ) ) (vla-put-Rotation VlaObjText LinAngle) (while (not (member (setq cambiar? (strcase (getstring "\n¿Rotar el texto? <No>/Si: "))) '("" "N" "NO" "S" "SI"))) (princ "\nOpcion seleccionada no valida. Repite, por favor...") ) (if (member cambiar? '("S" "SI")) (vla-put-Rotation VlaObjText (+ LinAngle PI)) ) (vlax-release-object VlaObjText) ) (vlax-release-object VlaObjLine) (setvar "cmdecho" 1) (princ) ) Edited March 10 by GLAVCVS 1 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.