Hellow, i'm trying to write a very simple code from scratch, i want it to read the angle position and width of a mtext. and if the angle is 0 (means the text is horizontal), then he performs a couple of replacements in code groups.
This is what I've manage to do:
(defun c:ter2 ( / entitysel enty position angle newposition newangle substituteangle substituteposition)(setq entitysel (car (entsel)) enty (entget entitysel) angle (assoc 50 enty) position (assoc 10 enty) mtextwidth (assoc 41 enty))(if(= angle 0) (setq newposition '(10 . (cadr(position)) (- caddr(position) 0.25)) ;gets the coordinate x and y and for y lowers 0.25, all of this in the variable newposition substituteposition (subst newposition position enty) ;defines something like a "method" that entmod will apply. ) (entmod substituteposition) ;replaces the position)(princ))
I know i can limit the object to mtext and i will implement a ssget later. But for now what i wanna know is why can't this code perform as i think he should, replacing the positioning of my text when he is horizontal
(defun c:ter2 ( / entitysel enty position _angle newposition newangle substituteangle substituteposition)(setq entitysel (car (entsel)) enty (entget entitysel) _angle (cdr (assoc 50 enty)) position (assoc 10 enty) mtextwidth (cdr (assoc 41 enty)))(if (= _angle 0) (progn (setq newposition (cons 10 (list (cadr position) (- (caddr position) 0.25))) ;gets the coordinate x and y and for y lowers 0.25, all of this in the variable newposition substituteposition (subst newposition position enty) ;defines something like a "method" that entmod will apply. ) (entmod substituteposition) ;replaces the position ) )(princ))
(vl-load-com)(defun c:ter2 (/ ent ins) (if (= (type (setq ent (vl-catch-all-apply (function (lambda () (ssget "_+.:S:E:L" '((0 . "MTEXT"))) ) ;_ end of lambda ) ;_ end of function ) ;_ end of vl-catch-all-apply ) ;_ end of setq ) ;_ end of type 'pickset ) ;_ end of = (progn (setq ent (vlax-ename->vla-object (ssname ent 0)) ins (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint ent))) ) ;_ end of setq (if (equal (vla-get-rotation ent) 0. 1e-3) (vla-put-insertionpoint ent (vlax-3d-point (list (car ins) (- (caddr ins)) 0.25))) ) ;_ end of if ) ;_ end of progn ) ;_ end of if ) ;_ end of defun