change text/mtext style INCLUDING properties

change text/mtext style INCLUDING properties

Anonymous
Not applicable
778 Views
3 Replies
Message 1 of 4

change text/mtext style INCLUDING properties

Anonymous
Not applicable

Same code, different problem 😕

 

I have this code that is suppose to change the style of text. Technically it does, but it doesn't bring over all the properties that are suppose to come with it, ie. Annotative setting and Height in particular. It seems to simply change the style name only!

(setq ss4 (ssget "X" (list (cons 0 "MTEXT")(cons 40 350.0)(cons 410 (getvar "ctab")))))
(if ss4
	(progn
		(setq C 0)
		(repeat (sslength ss4)
			(setq entx (ssname ss4 C))
			(setq ent (entget entx))
			(setq ent (subst (cons 7 "RMS - 2.5mm")(assoc 7 ent) ent))
			(entmod ent)
			(setq C (+ C 1))
		); repeat
	); progn
); if

 

Could anybody help me understand what is happening a bit better here? I feel like if I had a better understanding i would know which parts to change...

0 Likes
779 Views
3 Replies
Replies (3)
Message 2 of 4

Sea-Haven
Mentor
Mentor

You will need to repeat these 2 lines with the correct dxf code number use (entget (car (entsel "picjk text")) to see the dxf code numbers and values. Change the text and repeat the entget code to see values.

 

(setq ent (subst (cons 7 "RMS - 2.5mm")(assoc 7 ent) ent))
(entmod ent)

0 Likes
Message 3 of 4

ВeekeeCZ
Consultant
Consultant

Well... entmake could be difficult especially if comes to new things like annotativity

I would suggest to use newer functions... setpropertyvalue, getpropertyvalue or dumpallpropeties.

Then the code looks fairly easy. And it works as expected.

 

(if (and (setq ss (ssget (list '(0 . "*TEXT") '(40 . 350.0) (cons 410 (getvar "ctab")))))
	 (setq st (tblobjname "STYLE" "RMS - 2.5mm"))
	 )
  (repeat (setq i (sslength ss))
    (setpropertyvalue (ssname ss (setq i (1- i))) "TextStyleId" st)))

 

0 Likes
Message 4 of 4

dlanorh
Advisor
Advisor

@Anonymous wrote:

Same code, different problem 😕

 

I have this code that is suppose to change the style of text. Technically it does, but it doesn't bring over all the properties that are suppose to come with it, ie. Annotative setting and Height in particular. It seems to simply change the style name only!

(setq ss4 (ssget "X" (list (cons 0 "MTEXT")(cons 40 350.0)(cons 410 (getvar "ctab")))))
(if ss4
	(progn
		(setq C 0)
		(repeat (sslength ss4)
			(setq entx (ssname ss4 C))
			(setq ent (entget entx))
			(setq ent (subst (cons 7 "RMS - 2.5mm")(assoc 7 ent) ent))
			(entmod ent)
			(setq C (+ C 1))
		); repeat
	); progn
); if

 

Could anybody help me understand what is happening a bit better here? I feel like if I had a better understanding i would know which parts to change...


DXF Codes MText 

 

you can also look HERE  or HERE 

 

You can also change entity properties using setpropertyvalue AutoCAD Help Page 

I am not one of the robots you're looking for

0 Likes