@Anonymous wrote:
In paper space we zoom to our title block which is in model space using zoom-object. When we do that the object comes in close to scale (VPSCALE - PS:MS = 1:24.01428). Is there a way that I could create a lisp that will perform a zoom-object and then set the scale to the nearest set scale (PS:MS = 1:24). Our set scales would be 1:1, 1:2, 1:4, 1:8, 1:12, 1:16, 1:24, 1:32, 1:48, 1:64, 1:96. Any help on this would be great.
Try below code. Minimal testing and no error trap.
(defun c:somefunc (/ cvp dat3 ent etdata etdata2 ss1 zf)
(and (zerop (getvar 'tilemode))
(> (setq cvp (getvar 'cvport)) 1)
(setq ent (car (entsel "\nSelect object to zoom to: ")))
(vl-cmdf "._zoom" "_o" ent "")
(setq ss1 (ssget "_x" (list '(0 . "viewport") (cons 69 cvp) (cons 410 (getvar 'ctab)))))
(setq zf (/ (cdr (assoc 41 (setq etdata (entget (setq ent (ssname ss1 0)))))) (cdr (assoc 45 etdata)))
dat3 (mapcar '(lambda (x)
(cons (cdr (assoc 300 (setq etdata2 (entget (cdr x)))))
(apply '/ (reverse (cdr (reverse (mapcar 'cdr (member (assoc 140 etdata2) etdata2))))))))
(vl-remove-if-not '(lambda (x) (= 350 (car x))) (dictsearch (namedobjdict) "ACAD_SCALELIST"))))
(setpropertyvalue ent
"ViewHeight"
(/ (cdr (assoc 41 etdata))
(cdr (assoc (caar (vl-sort (mapcar '(lambda (x) (cons (car x) (abs (- zf (cdr x))))) dat3)
'(lambda (x y) (< (cdr x) (cdr y)))))
dat3)))))
(princ))
