Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Lisp Routine to Scale Text Objects

6 REPLIES 6
Reply
Message 1 of 7
zootango
2398 Views, 6 Replies

Lisp Routine to Scale Text Objects

Anyone have a Lisp Routine to scale text objects a certain value and have the program actually scale each text object as you pick them.

 

The change text height using the Properties function does not work for what I need because the objects I need to scale are Mtext objects with

Background Mask, and when you use the Properties function to change their text height it messes up the background mask so that you have to

select each text entity and stretch the mask area smaller or larger, but if you use the scale function it scales the background mask as well so the

background mask coverage is still the same.

 

Anybody have a lisp?

 

6 REPLIES 6
Message 2 of 7
Lee_Mac
in reply to: zootango

Here is a quick draft that should perform as you require:

 

(defun c:smt ( / i o s )
    (initget 6)
    (setq smt:scl
        (cond
            (   (getdist
                    (strcat
                        "\nSpecify scale factor <"
                        (rtos (cond (smt:scl) (2.0)))
                        ">: "
                    )
                )
            )
            (   smt:scl   )
            (   2.0   )
        )
    )
    (if (setq s (ssget "_:L" '((0 . "MTEXT"))))
        (repeat (setq i (sslength s))
            (vla-scaleentity
                (setq o (vlax-ename->vla-object (ssname s (setq i (1- i)))))
                (vla-get-insertionpoint o)
                smt:scl
            )
        )
    )
    (princ)
)
(vl-load-com) (princ)
                
Message 3 of 7
gccdaemon
in reply to: zootango

I generally set my MTEXT to 0 width and 0 height (except numbered notes) and the background mask moves with the text.

Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
Message 4 of 7
gerben.schmidt
in reply to: Lee_Mac

Hi Lee,

 

How do you scale the TEXT and MTEXT objects based on their Justification Point?

The selected TEXT objects of my drawings have different Justifications like LEFT, RIGHT, CENTER, TL, TC, TR, ML, MC, etc.

I can't figure out how to do that

 

Greetzzz,

 

Gerben

 

 

 

 

 

Message 5 of 7
Lee_Mac
in reply to: gerben.schmidt

Hi Gerben,

 

The following should perform as you require:

 

(defun c:smt ( / i o s )
    (initget 6)
    (setq smt:scl
        (cond
            (   (getdist
                    (strcat
                        "\nSpecify scale factor <"
                        (rtos (cond (smt:scl) (2.0)))
                        ">: "
                    )
                )
            )
            (   smt:scl   )
            (   2.0   )
        )
    )
    (if (setq s (ssget "_:L" '((0 . "TEXT,MTEXT"))))
        (repeat (setq i (sslength s))
            (vla-scaleentity
                (setq o (vlax-ename->vla-object (ssname s (setq i (1- i)))))
                (if (or (= "AcDbMText" (vla-get-objectname o))
                        (= acalignmentleft (vla-get-alignment o))
                    )
                    (vla-get-insertionpoint o)
                    (vla-get-textalignmentpoint o)
                )
                smt:scl
            )
        )
    )
    (princ)
)
(vl-load-com) (princ)

 

Message 6 of 7
gerben.schmidt
in reply to: Lee_Mac

You're the best!

 

Greetzzz...

Message 7 of 7
Lee_Mac
in reply to: gerben.schmidt

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost