amcdicsac Posted December 6, 2016 Share Posted December 6, 2016 Hi. I have this code that inserts a text using grread function to which I want to add the option to rotate and resize but I have no idea how to do it would appreciate the help. Thanks (defun c:xaa (/ potencia prefijo pt) (setvar "cmdecho" 0) (setq potencia (strcase (getstring T "\nIngresa potencia monofásica: "))) (setq prefijo (*AX_mtext* (strcat potencia "\\P" "1Ø/220V"))) (while (eq (car (setq pt (grread t 15 0))) 5) (redraw) (entmod (subst (cons 10 (cadr pt)) (assoc 10 (entget prefijo)) (entget prefijo)))) (setvar "cmdecho" 1) (princ)) (defun *AX_mtext* (s) (entmakex (list (cons 0 "MTEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbMText") (list 10 0. 0. 0.) (list 11 0. 0. 0.) (cons 71 1) (cons 40 0.2) (cons 1 s) (cons 7 "0-DEU-ROMANS") ) ) ) Quote Link to comment Share on other sites More sharing options...
Grrr Posted December 6, 2016 Share Posted December 6, 2016 Hi, What should be the rotation angle? By resize you mean to increase its height by "n" units or scale it? Quote Link to comment Share on other sites More sharing options...
amcdicsac Posted December 6, 2016 Author Share Posted December 6, 2016 The angle of rotation would have to be 90, 180, 270 and 360, with respect to the height would be better to increase it by units Quote Link to comment Share on other sites More sharing options...
Grrr Posted December 6, 2016 Share Posted December 6, 2016 Okay, the height increment is set to 0.1 units: (defun C:test ( / potencia prefijo msg enx n sizeInc cmd grr ) (if (and (setq potencia (strcase (getstring T "\nIngresa potencia monofásica: "))) (setq prefijo (*AX_mtext* (strcat potencia "\\P" "1Ø/220V"))) (setq msg "\nPress [+/-] to increase/decrease the size, [TAB] to rotate <exit>: ") (setq enx (entget prefijo)) (setq n (cdr (assoc 40 enx))) (setq sizeInc 0.1) ); and (progn (setq cmd (getvar 'cmdecho)) (setvar 'cmdecho 0) (and msg (princ msg)) (setvar 'errno 0) (while (/= 52 (getvar 'errno)) (setq grr (grread T)) (cond ((= (car grr) 2) (and msg (princ msg)) (and (= (chr (cadr grr)) "\r") (setvar 'errno 52)) (cond ((= (chr (cadr grr)) "+") (setq n (+ n sizeInc)) (entmod (setq enx (subst (cons 40 n) (assoc 40 enx) enx))) ) ((= (chr (cadr grr)) "-") (setq n (- n sizeInc)) (or (not (minusp n)) (setq n 0.1)) (entmod (setq enx (subst (cons 40 n) (assoc 40 enx) enx))) ) ((= (cadr grr) (ascii (strcase "\t" T))) (entmod (setq enx (subst (cons 50 (+ (cdr (assoc 50 enx)) (/ PI 2.))) (assoc 50 enx) enx))) ) ); cond ) ( (= (car grr) 25) (setvar 'errno 52) ) ( (= (car grr) 5) (and msg (princ msg)) (entmod (subst (cons 10 (cadr grr)) (assoc 10 (entget prefijo)) (entget prefijo))) ) ( (= (car grr) 3) (setvar 'errno 52) ) ); cond ); while (and cmd (setvar 'cmdecho cmd)) ); progn ); if (princ) ); defun C:test (defun *AX_mtext* (s) (entmakex (list (cons 0 "MTEXT") (cons 100 "AcDbEntity") (cons 100 "AcDbMText") (list 10 0. 0. 0.) (list 11 0. 0. 0.) (cons 71 1) (cons 40 0.2) (cons 1 s) (cons 7 "0-DEU-ROMANS") ) ) ) Quote Link to comment Share on other sites More sharing options...
amcdicsac Posted December 6, 2016 Author Share Posted December 6, 2016 thanks Grr was just what I needed Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted December 6, 2016 Share Posted December 6, 2016 @Grrr: Your use of the errno variable is very peculiar. The errno variable when set by the CAD program has a very specific meaning. I am not saying that what you are doing is wrong, but using your own (boolean) variable instead would make more sense. Quote Link to comment Share on other sites More sharing options...
Grrr Posted December 6, 2016 Share Posted December 6, 2016 @Grrr:Your use of the errno variable is very peculiar. The errno variable when set by the CAD program has a very specific meaning. I am not saying that what you are doing is wrong, but using your own (boolean) variable instead would make more sense. @Roy, the whole thing started when I was learning about "pseudo loops", mostly from Lee Mac's codes. Figured out that it has such potential, instead of localizing a new variable with setq function, overall I'm trying to reduce the amount of setq's. Thanks for posting this, it will shed more light. Quote Link to comment Share on other sites More sharing options...
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.