Jump to content

LISP newbie help...


ARainey

Recommended Posts

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!

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...