Text height change by lisp

Text height change by lisp

Anonymous
Not applicable
11,095 Views
22 Replies
Message 1 of 23

Text height change by lisp

Anonymous
Not applicable

Hi,

 

I am looking lisp for changing text height. I have to change Mtext  height 100 to 150 in my drawing.

I know using by filter commend. I have to know change by lisp.

I hope any one can help me..

 

Thanks for advance.

 

sujinkutti.

0 Likes
Accepted solutions (1)
11,096 Views
22 Replies
Replies (22)
Message 2 of 23

Kent1Cooper
Consultant
Consultant

That should not be difficult, provided none of the Mtext has any internal  height assignments overriding the height of the Mtext object as a whole.  Do you need to change all  Mtext to a height of 150, or only Mtext that currently is 100 units high, leaving others alone?

Kent Cooper, AIA
0 Likes
Message 3 of 23

Anonymous
Not applicable

Hi..

 

I need to change only Mtext 100 to 150 other should be alone.

 

Thank you

sujinkutti..

 

0 Likes
Message 4 of 23

Kent1Cooper
Consultant
Consultant

You can do this with QSELECT:

MtextHeight100.png

then in the Properties palette you can change the height of all of them at once.

Kent Cooper, AIA
0 Likes
Message 5 of 23

Anonymous
Not applicable

Hi,

Thanks for your reply,

 

I know the Qselect & filter comments, i'm asking about the Autocad lisp.

 

Regards,

sujinkutti

0 Likes
Message 6 of 23

pendean
Community Legend
Community Legend
0 Likes
Message 7 of 23

Anonymous
Not applicable

@pendean wrote:
the LISP forum is over here https://forums.autodesk.com/t5/autocad-customization/ct-p/AutoCADTopic1



There is no this kind of answer...

 

Any one please advice me.

It's very helpful to me.

I have to change all Mtext height 100 to 150...

 

Thanks and regards,

Sujinkutti. 

 

0 Likes
Message 8 of 23

dbhunia
Advisor
Advisor
Accepted solution

Hi

 

Try this........

 

This only for "MTEXT"........

 

(defun C:DEBA ( / ff1 xx1)

(Setq selectionset (ssget "_A" '((0 . "MTEXT") (40 . 100.0))))
(repeat (setq N (sslength selectionset))
(setq Data (ssname selectionset (setq N (- N 1))))
(setq EntityData (entget Data))
(setq ff1(assoc 40 EntityData))
(setq xx1 (cons 40 150.0))
(entmod(subst xx1 ff1 EntityData))
)
(princ)
)


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

Anonymous
Not applicable

@dbhunia wrote:

Hi

 

Try this........

 

This only for "MTEXT"........

 

(defun C:DEBA ( / ff1 xx1)

(Setq selectionset (ssget "_A" '((0 . "MTEXT") (40 . 100.0))))
(repeat (setq N (sslength selectionset))
(setq Data (ssname selectionset (setq N (- N 1))))
(setq EntityData (entget Data))
(setq ff1(assoc 40 EntityData))
(setq xx1 (cons 40 150.0))
(entmod(subst xx1 ff1 EntityData))
)
(princ)
)


Hi..

Thanks for the reply.

 

It's working, It's awesome...

 

Thank you very much..

Sujinkutti. 

0 Likes
Message 10 of 23

piyush.parihar24
Advocate
Advocate



 

 


Command: DEBA
; error: bad argument type: lselsetp nil
Above error for below LISP

@dbhunia wrote:

Hi

 

Try this........

 

This only for "MTEXT"........

 

(defun C:DEBA ( / ff1 xx1)

(Setq selectionset (ssget "_A" '((0 . "MTEXT") (40 . 100.0))))
(repeat (setq N (sslength selectionset))
(setq Data (ssname selectionset (setq N (- N 1))))
(setq EntityData (entget Data))
(setq ff1(assoc 40 EntityData))
(setq xx1 (cons 40 150.0))
(entmod(subst xx1 ff1 EntityData))
)
(princ)
)


0 Likes
Message 11 of 23

ВeekeeCZ
Consultant
Consultant

@piyush.parihar24 wrote:



 

 


Command: DEBA
; error: bad argument type: lselsetp nil
Above error for below LISP

@dbhunia wrote:

Hi

 

Try this........

 

This only for "MTEXT"........

 

(defun C:DEBA ( / ff1 xx1)

(Setq selectionset (ssget "_A" '((0 . "MTEXT") (40 . 100.0))))
(repeat (setq N (sslength selectionset))
(setq Data (ssname selectionset (setq N (- N 1))))
(setq EntityData (entget Data))
(setq ff1(assoc 40 EntityData))
(setq xx1 (cons 40 150.0))
(entmod(subst xx1 ff1 EntityData))
)
(princ)
)



 

0 Likes
Message 12 of 23

okarim6RZ7U
Participant
Participant

It doesn't modify all my Mtext. 😢

0 Likes
Message 13 of 23

ВeekeeCZ
Consultant
Consultant

MTEXT uses two ways of defining text height:

 

- the height property, which is changed by the above routine - GREEN

- formatting characters, which could be applied just on a portion of text - RED

 

BeekeeCZ_0-1662450357913.png

 

Google for STRIPMTEXT routine. It can remove all/some formatting characters if that is your issue.

0 Likes
Message 14 of 23

okarim6RZ7U
Participant
Participant

I ran a stripMText lisp for height. But it still doesn't affect RED after running the above routine. How do I make RED and GREEN match?

 

Like you said all values of GREEN are changed by the above routine. Is there a routine for RED?

0 Likes
Message 15 of 23

ВeekeeCZ
Consultant
Consultant

Generally, when you remove the char-formatting overrides, the above routine should work. Another thing is annotative scaling.

Post some dwg example to take a look.

0 Likes
Message 16 of 23

okarim6RZ7U
Participant
Participant

okarim6RZ7U_0-1662470503548.png

There are three text sizes even after running both routines. To make sure the stripMText works, I'm able to clear the linefeed that makes each text written on a single line. The height, however, is what I'm after. 

 

GREEN for all the text is the same too (meaning the above routine also works). I just don't know how to match the GREEN and RED.

0 Likes
Message 17 of 23

ВeekeeCZ
Consultant
Consultant

Again and lastly, post a dwg. Before and target states.

0 Likes
Message 18 of 23

okarim6RZ7U
Participant
Participant

Alright.

0 Likes
Message 19 of 23

Kent1Cooper
Consultant
Consultant

@piyush.parihar24 wrote:

Command: DEBA
; error: bad argument type: lselsetp nil
....

(Setq selectionset (ssget "_A" '((0 . "MTEXT") (40 . 100.0))))
....

(setq xx1 (cons 40 150.0))
....



That's because none of your Mtext objects have a height of 100 units that the code is looking for, but they're all [ignoring internal height formatting, or after STRIPMTEXTing them] defined with a height of 3/16".  [And even with internal overrides, they're 12 or 24 units in height, so I assume you do not want to change them to 150 units.]  So, since none of them have the height the code is looking for, the (ssget) function sees none of them, and the selection set is empty, which is exactly what the error message is about.

Kent Cooper, AIA
0 Likes
Message 20 of 23

ВeekeeCZ
Consultant
Consultant

From your target dwg it's not clear what your goal is.

 

Here I made a video before you posted the target.

https://autode.sk/3QmwP7k

 

My goal was to set all texts to the height of 24 (copied to the metric template).

 

HTH

 

0 Likes