I can't seem to get this to work. It seems that it only scales the items (Mtext) inside the Mtext editor not on the screen. What am I doing wrong?
(defun c:rescale (/ ss val idx obj)
(princ "\nSelect text and or blocks to rescale: ")
(if (setq ss (ssget '((0 . "TEXT,MTEXT,INSERT"))))
(progn
(if (not *rescale*)
(setq *rescale* 0.5)
)
(if (setq val (getreal (strcat "\nRescale by what value?<" (rtos *rescale* 2 2) ">: ")))
(setq *rescale* val)
)
(setq idx -1)
(while (< (setq idx (1+ idx))(sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss idx)))
(cond ((wcmatch (vla-get-objectname obj) "*Block*")
(vla-put-xscalefactor obj (* (vla-get-xscalefactor obj) *rescale*))
(vla-put-yscalefactor obj (* (vla-get-yscalefactor obj) *rescale*))
(vla-put-zscalefactor obj (* (vla-get-zscalefactor obj) *rescale*))
)
(T
(vla-put-height obj (* (vla-get-height obj) *rescale*))
)
)
)
)
)
(princ)
)
(defun c:iScale ( / _IScale _GetReal _Main )
(defun _IScale ( object factor )
;; trap locked layer errors
(vl-catch-all-apply
'(lambda ()
(cond
;; make it easy to add other objects in the future
( (vlax-property-available-p object 'XScaleFactor)
(foreach property
'(XScaleFactor YScaleFactor ZScaleFactor)
(vlax-put-property
object
property
(* factor (vlax-get-property object property))
)
)
)
( (vlax-property-available-p object 'Height)
(vla-put-height
object
(* factor
(vla-get-height object)
)
)
)
)
)
)
)
(defun _GetReal ( pmt default initgetbits / response )
(if (eq 'int (type initgetbits))
(initget (logand (~ 1) initgetbits))
)
(if
(setq response
(getreal
(strcat
pmt
" <"
(rtos default 2 3)
">: "
)
)
)
response
default
)
)
(defun _Main ( / ss i )
(princ "\nSelect (m)text, attdefs or inserts to iScale: ")
(cond
( (setq ss (ssget '((0 . "text,mtext,attdef,insert"))))
(setq *IScaleFactor*
(_GetReal
"\nEnter scaling factor"
(if (numberp *IScaleFactor*)
*IScaleFactor*
0.5
)
(+ 2 4)
)
)
(repeat (setq i (sslength ss))
(_IScale
(vlax-ename->vla-object
(ssname ss (setq i (1- i)))
)
*IScaleFactor*
)
)
)
)
(princ)
)
(_Main)
)