Text entity position change after type of allignment change

Text entity position change after type of allignment change

davidkoh007
Contributor Contributor
1,229 Views
6 Replies
Message 1 of 7

Text entity position change after type of allignment change

davidkoh007
Contributor
Contributor

Hi, how can I return a text entity into it's previous position after I change it's allignment type? And I need to use entmod, not (command "_move").

 

(setq edent (entget textEntity)
(setq c73o (assoc 73 edent))
(setq c73n (cons 73 2))
(setq edent (subst c73n c73o edent))
(entmod edent)

After this routine the text changes its position a bit, I want to return it to its previous location, but I need to keep the 73 group as 2 (middle).

0 Likes
Accepted solutions (2)
1,230 Views
6 Replies
Replies (6)
Message 2 of 7

dbhunia
Advisor
Advisor

Try like this

(setq Ent_text (car(entsel)))
(setq Obj_text (vlax-ename->vla-object ent_text))
(setq Ins_Point (vlax-safearray->list (vlax-variant-value (vla-get-InsertionPoint Obj_text))))
(vla-put-alignment Obj_text 9)
(entmod (subst (cons 11 Ins_Point) (assoc 11 (entget Ent_text)) (entget Ent_text)))

OR

 

(setq edent (entget (car (entsel))))
(setq c10 (cdr (assoc 10 edent)))
(setq c40 (cdr (assoc 40 edent)))
(setq c73o (assoc 73 edent))
(setq c73n (cons 73 2))
(setq edent (subst c73n c73o edent))
(setq edent (subst (cons 11 (list (car c10) (+ (cadr c10) (/ c40 2.0)) (caddr c10))) (assoc 11 edent ) edent ))
(entmod edent)

Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 3 of 7

davidkoh007
Contributor
Contributor

Thank you very much. Used the second method altough it used wrong coordinate change at X axis.

 

fixed with

(setq c11 (cdr (assoc 11 edent)))
(setq edent (subst (cons 11 (list (car c11) (+ (cadr c10) (/ c40 2.0)) (caddr c10))) (assoc 11 edent ) edent ))
0 Likes
Message 4 of 7

davidkoh007
Contributor
Contributor

E: But apparently it doesn't work properly anyway if the text is rotated.

Still lookin for solution.

0 Likes
Message 5 of 7

ВeekeeCZ
Consultant
Consultant
Accepted solution
  (setq ent (car (entsel)))
  (setq in0 (cdr (assoc 10 (entget ent)))) ; original ins
  (entmod (subst '(73 . 2) (assoc 73 (entget ent)) (entget ent)))
  
  (setq ins (cdr (assoc 10 (entget ent)))) ; new ins
  (setq alg (cdr (assoc 11 (entget ent)))) ; new alg

  (entmod (subst (cons 11 (polar in0 (angle ins alg) (distance ins alg))) (assoc 11 (entget ent)) (entget ent)))
0 Likes
Message 6 of 7

davidkoh007
Contributor
Contributor
Accepted solution

Díky Vilíku!/ Thanks, helped me a lot!

 

Figured out today, 72 . 4 will work best for my purposes, used this in the end

 

(setq edent (entget textEntity))
(setq c10o (cdr (assoc 10 edent))) (setq c72o (assoc 72 edent)) (setq c72n (cons 72 4)) (setq edent (subst c72n c72o edent)) (entmod edent) (setq edent (entget textEntity)) ; I couldnt figure out I have to do this step again, otherwise old ins point coords would be the same as after entmod... (setq c10n (cdr (assoc 10 edent))) (setq x_dif (-(abs (nth 0 c10n)) (abs (nth 0 c10)))) (setq y_dif (-(abs (nth 1 c10n)) (abs (nth 1 c10)))) (entmod (subst (cons 11 (list (+ x_dif (nth 1 (assoc 11 edent))) (+ y_dif (nth 2 (assoc 11 edent))) 0.0 )) (assoc 11 edent) edent))
0 Likes
Message 7 of 7

ВeekeeCZ
Consultant
Consultant

Glad to help.

Yep, it's pitty that entmod returns the same old list as it got. Not the updated one.

 

(defun c:Test ()
  (setq ent (car (entsel)))
  (princ "\nOld def list: ") (print (setq edo (subst '(73 . 4) (assoc 73 (entget ent)) (entget ent))))
  (princ "\nStill old list: ") (print (entmod edo))
  (princ "\nNew def list: ") (print (entget ent))
  (princ)
  )
0 Likes