The following the the lisp routine I created.
You can use it as you wish.
If you have any suggentions please post them!
;Program Name: port
;Description: This program will draw a polyline in model space at the extents of the current view port.
; The polyline will be drawn on layer Viewport.
; The user must be inside a viewport when this command is run
;
;Programmer: Kevin Petursson
;Date: July 16, 2003
;Revision: 1.0
;
;
(defun C

ort (/ VPctr TMode VP VPsize Currentlayer temp LL UR ctrx ctry LLx LLy URx URy ModelWidth p1 p2 p3 p4)
(setvar "CMDECHO" 0)
(setq VPctr (getvar "VIEWCTR"

) ;centrepoint of viewport
(setq TMode (getvar "tilemode"

)
(setvar "tilemode" 0)
(setq VP (vports)) ;Get info on the viewports
(setq VPsize (getvar "Viewsize"

) ;get the height in model space of the current view port
(setq Currentlayer (getvar "clayer"

) ;Get the current layer
;Change the following line to draw the polyline on a different layer
(setvar "clayer" "Viewport"

;Set the current layer to Viewport
(setq temp (nth 0 VP))
(setq LL (nth 1 temp))
(setq UR (nth 2 temp))
(setq
ctrx (nth 0 VPctr)
ctry (nth 1 VPctr)
LLx (nth 0 LL)
LLy (nth 1 LL)
URx (nth 0 UR)
URy (nth 1 UR)
ModelWidth (* (- URx LLx) (/ VPsize (- LLy URy)))
)
(setq
p1 (list (- ctrx (/ modelwidth 2)) (- ctry (/ VPsize 2)))
p2 (list (- ctrx (/ modelwidth 2)) (+ ctry (/ VPsize 2)))
p3 (list (+ ctrx (/ modelwidth 2)) (+ ctry (/ VPsize 2)))
p4 (list (+ ctrx (/ modelwidth 2)) (- ctry (/ VPsize 2)))
)
(command "pline" p1 p2 p3 p4 "close"

(setvar "clayer" currentlayer) ;Reset the current layer
(setvar "tilemode" TMode)
(setvar "CMDECHO" 1)
(princ)
)
Kevin Petursson
Dogs come when they're called.
Cats come when they're interested!