ARainey Posted July 21, 2011 Share Posted July 21, 2011 Very new to lisp and wondering how to get a list of points (eg X1 Y1 X2 Y2) or draw a rectangle at the current extent of my drawing space. I need to be able to perform this at any zoom, in other words, not just zoom extents and I dont need the limits of the drawing, just a box drawn around what is currently displyed. thanks all! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 22, 2011 Share Posted July 22, 2011 The following function will return a list of the extents of the current view: (defun LM:WindowExtents nil ;; © Lee Mac 2011 ( (lambda ( c v ) (list (trans (mapcar '- c v) 1 0) (trans (mapcar '+ c v) 1 0))) (getvar 'VIEWCTR) ( (lambda ( h s ) (list (* h s) h)) (/ (getvar 'VIEWSIZE) 2.) (apply '/ (getvar 'SCREENSIZE)) ) ) ) Which you could call with the Rectang command: (defun c:test ( / lst ) (setq lst (LM:WindowExtents)) (command "_.rectang" "_non" (car lst) "_non" (cadr lst)) (princ) ) Or, perhaps with entmake (the following will also work in all UCS/Views): (defun c:test ( / lst nrm ) (setq nrm (trans '(0. 0. 1.) 1 0 t) lst (mapcar 'trans (LM:WindowExtents) '(0 0) (list nrm nrm)) ) (entmakex (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 4) (cons 70 1) (cons 10 (car lst)) (cons 10 (list (caadr lst) (cadar lst))) (cons 10 (cadr lst)) (cons 10 (list (caar lst) (cadadr lst))) (cons 210 nrm) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.