;; PICKBOXCOORD
;; Pick Box Coordinates
;; Returns coordinates (list of 4 points defining a square) that are planar to the current display view, relative to the current pickbox size, and centred about the given point.
;; the given centre point must be in WCS
;; returned points are also in WCS
;; Includes an option to apply a scale factor to the current PICKBOX value.
;;
;; e.g for
;; (setvar 'PICKBOX 6) and in plan view
;; (PICKBOXCOORD (trans (getpoint) 1 0) 1)
;; ((72.0287613899495 74.940245442679 0.0) (72.0287613899495 75.8325809183257 0.0) (72.9210968655962 75.8325809183257 0.0) (72.9210968655962 74.940245442679 0.0))
;; (PICKBOXCOORD '(0 0 0) 1)
;; ((-0.446167737823339 -0.446167737823339 0.0) (-0.446167737823339 0.446167737823339 0.0) (0.446167737823339 0.446167737823339 0.0) (0.446167737823339 -0.446167737823339 0.0))
;; (PICKBOXCOORD '(0 0 0) 10)
;; ((-4.46167737823339 -4.46167737823339 0.0) (-4.46167737823339 4.46167737823339 0.0) (4.46167737823339 4.46167737823339 0.0) (4.46167737823339 -4.46167737823339 0.0))
(defun PickBoxCoord
( pctr factor
/ ratio pbox2
) ;;VIEWSIZE ; Current height of the viewport in drawing units
;;SCREENSIZE ; x,y size of the viewport in pixels
(setq ratio
(/ (getvar 'VIEWSIZE
) (cadr (getvar 'SCREENSIZE
)))) ; ratio between drawing units and pixels (setq pbox2
(* (getvar 'PICKBOX
) ratio
0.5 factor
)) ; get 1/2 the current pickbox size in drawing units and apply factor if given (setq pctr
(trans pctr
0 2)) ; convert the given point to display coordinates ;; Create a point list of each of the four corners
(list (- (car pctr
) pbox2
) (- (cadr pctr
) pbox2
) (caddr pctr
)) ; bottom left corner (list (- (car pctr
) pbox2
) (+ (cadr pctr
) pbox2
) (caddr pctr
)) ; top left corner (list (+ (car pctr
) pbox2
) (+ (cadr pctr
) pbox2
) (caddr pctr
)) ; top right corner (list (+ (car pctr
) pbox2
) (- (cadr pctr
) pbox2
) (caddr pctr
)) ; bottom right corner )
)
)