Hi,
If your ACAD version allows it, you can use the the option "object" of ZOOM command: (vl-cmdf "_.zoom" "_o" (ssget) "")
If it don't or if you'd rather not using command, I wrote a ZoomObject routine (cause vla-ZoomObject isn't provided)
;; ZoomObject
;; Zoom on objects countained in a list
;;
;; Argument
;; objlst : a vla-objects list
;;
;; Variables
;; dir : normal vector of the current view plane
;; ang : Twist angle of the current view
;; 3x3 : 3x3 transformation matrix fron WCS to current view
;; 4x4 : 4x4 transformation matrix fron WCS to current view
;; ptlst : list of all min and max points of objects bounding boxes
(defun ZoomObject (objlst / dir ang 3x3 4x4 ptlst)
(vl-load-com)
(setq dir (trans '(0 0 1) 2 0 T)
ang (- (getvar "viewtwist"))
3x3 (mxm (mapcar '(lambda (x) (trans x 0 dir))
'((1 0 0) (0 1 0) (0 0 1))
)
(list (list (cos ang) (- (sin ang)) 0)
(list (sin ang) (cos ang) 0)
'(0 0 1)
)
)
4x4 (append
(mapcar
'(lambda (v o)
(append v (list o))
)
3x3
'(0 0 0)
)
(list '(0 0 0 1))
)
)
(foreach obj objlst
(vla-TransformBy obj (vlax-tmatrix (trp 4x4)))
(vla-getBoundingBox obj 'minpt 'maxpt)
(vla-TransformBy obj (vlax-tmatrix 4x4))
(setq ptlst (cons (vlax-safearray->list minpt)
(cons (vlax-safearray->list maxpt) ptlst)
)
)
)
(vla-ZoomWindow
(vlax-get-acad-object)
(vlax-3d-point (mxv 3x3 (apply 'mapcar (cons 'min ptlst))))
(vlax-3d-point (mxv 3x3 (apply 'mapcar (cons 'max ptlst))))
)
)
;; transpose a matrix by Doug Wilson
(defun trp (m)
(apply 'mapcar (cons 'list m))
)
;; Apply a transformation matrix to a vector by Vladimir Nesterovsky
(defun mxv (m v)
(mapcar '(lambda (r) (apply '+ (mapcar '* r v))) m)
)
;; Multiply two matrices by Vladimir Nesterovsky
(defun mxm (m q)
(mapcar '(lambda (r) (mxv (trp q) r)) m)
)
A test/calling function:
(defun c:zo (/ lst)
(vl-load-com)
(or *acdoc*
(setq *acdoc* (vla-get-ActiveDocument (vlax-get-acad-object)))
)
(if
(ssget)
(progn
(vla-StartUndoMark *acdoc*)
(ZoomObject
(vlax-for o (vla-get-ActiveSelectionSet *acdoc*)
(setq lst (cons o lst))
)
)
(vla-EndUndoMark *acdoc*)
)
)
(princ)
)