Nice coding Kruuger I tweaked it a little for a more intuitive input:
(defun c:test ( / p1 p2 )
;; Kruuger's code, tweaked by Lee Mac
(if
(and
(setq p1 (getpoint "\nSpecify First Corner of Viewport: "))
(setq p2 (getcorner "\nSpecify Opposite Corner of Viewport: " p1))
)
(progn
(setq p1 (trans p1 1 0)
p2 (trans p2 1 0)
)
(vla-Display
(vla-AddPViewport
(vla-Get-PaperSpace (vla-Get-ActiveDocument (vlax-Get-Acad-Object)))
(vlax-3D-Point (mapcar '(lambda ( a b ) (/ (+ a b) 2.)) p1 p2))
(abs (- (car p1) (car p2)))
(abs (- (cadr p1) (cadr p2)))
)
:vlax-true
)
)
)
(princ)
)