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

Lisp routine. Find Mtext content then scale all entities by what is found

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
1007 Views, 5 Replies

Lisp routine. Find Mtext content then scale all entities by what is found

I'm looking for a lisp routine that will find a certaind mtext (i.e. "1:2" "1:4" "1:5" "1:20" - which exist only 1 time) in the drawing then scale all entities by the factor given in the mtext. If there is mtext with content "1:5" - I want lisp to scale all entities by the factor of 5. If there is mtext "1:20" - scale entities by 20.

This will be a part of modification of multiple drawings. For now I'm doing it by script (which is loading .lsp routines)

I'll appreciate any kind of help.

 

kind regards

Jakub

5 REPLIES 5
Message 2 of 6
pbejse
in reply to: Anonymous


@Anonymous wrote:

I'm looking for a lisp routine that will find a certaind mtext (i.e. "1:2" "1:4" "1:5" "1:20" - which exist only 1 time) in the drawing then scale all entities by the factor given in the mtext. If there is mtext with content "1:5" - I want lisp to scale all entities by the factor of 5. If there is mtext "1:20" - scale entities by 20.

This will be a part of modification of multiple drawings. For now I'm doing it by script (which is loading .lsp routines)

I'll appreciate any kind of help.

 

kind regards

Jakub



Its easy to find those text, my concerned is the basepoint reference when scaling the entities.

Did you mean ALL entities using one basepoint? 

 

Message 3 of 6
Anonymous
in reply to: Anonymous

Basepoint doesn't matter at all, i'd say 0,0,0 is fine. Te mtext i want to find is the only text containing ':' - so, it should be much easier to find it and read as a scale factor (found '1:5' >> scale factor is 5; but i've noticed that in some drawings it could be a 2-digit number - '1:20' >> scale factor is 20). I think search list will be: '1:' 1, 2, 3, 4, 5, 10, 16, 20, 50. To avoid mistakes (over 2k files to proceed) i was thinking to insert a text 'no scale found' when the routine can't find any od the listed values od mtext.
Message 4 of 6
pbejse
in reply to: Anonymous


@Anonymous wrote:
Basepoint doesn't matter at all, i'd say 0,0,0 is fine. Te mtext i want to find is the only text containing ':' - so, it should be much easier to find it and read as a scale factor (found '1:5' >> scale factor is 5; but i've noticed that in some drawings it could be a 2-digit number - '1:20' >> scale factor is 20). I think search list will be: '1:' 1, 2, 3, 4, 5, 10, 16, 20, 50. To avoid mistakes (over 2k files to proceed) i was thinking to insert a text 'no scale found' when the routine can't find any od the listed values od mtext.

Try this for now, we'll develop it as we go.

 

(defun c:test ( / ss p str)
(if (and (setq ss (ssget "_X" '((0 . "MTEXT")
         (1 . "*#:#*")(410 . "MODEL"))))
         (= 1 (sslength ss))
         (setq p (vl-string-position
               (ascii ":")
               (setq str  (cdr (assoc 1
               (entget (ssname ss 0)))))))
         )
	(command "_Scale" "_All" ""
	          "0,0" (atoi (substr str (+ p 2))))
    	(princ "\nNo Scale Found/More than one reference Found:")
    )
      (princ)
      )

 

 

HTH

 

Message 5 of 6
Anonymous
in reply to: Anonymous

That works great.

Many thanks

Message 6 of 6
pbejse
in reply to: Anonymous


@Anonymous wrote:

That works great.

Many thanks



Good for you and you're welcome

 

Cheers

 

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

Post to forums  

Autodesk Design & Make Report

”Boost