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
Solved! Go to Solution.
Solved by pbejse. Go to Solution.
@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?
@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