3dwannab Posted July 21, 2022 Posted July 21, 2022 I have this simple code below to pick the lower corner, the rotation and then the upper far corner which is handy for tracing maps with rectangular buildings on them. I would like to preview the rectangle getting drawn. Maybe it's late but I can't see how to do this easily without grread but perhaps there is. ;; Idea from this: https://www.theswamp.org/index.php?topic=55203.msg594646#msg594646 ;; TO DO: ;; Add proper undo handling ;; Show preview of the rectangle (defun C:Survey_Rectangle (/ pt1 pt2 ptr) (if (and (setq pt1 (getpoint "\nBottom left corner :")) (setq ptr (getpoint "\nRotation :")) (setq pt2 (getpoint pt1 "\nTop Right corner :")) ) (progn (command "_.rectang" pt1 "_R" ptr pt2) (command "_.rectang" pt1 "_R" 0 \) ;; Set the rectangle rotation back to 0 without going into the command ) ) ) (c:Survey_Rectangle) Quote
marko_ribar Posted July 21, 2022 Posted July 21, 2022 You can do it with temporarily changing UCS rotation and just processing RECTANGLE command... (defun c:foo ( / *error* ucsf ll lr ) (defun *error* ( m ) (if ucsf (if command-s (command-s "_.UCS" "_P") (vl-cmdf "_.UCS" "_P") ) ) (if m (prompt m) ) (princ) ) (if (= 0 (getvar 'worlducs)) (progn (vl-cmdf "_.UCS" "_W") (setq ucsf t) ) ) (vl-cmdf "_.UCS" "_Z" (cvunit (getangle (setq ll (getpoint "\nBase point : ")) (setq lr (getpoint "\nDirection : ")) "radian" "degree")) (vl-cmdf "_.RECTANGLE" "_non" (trans ll 0 1) "\\") (*error* nil) ) 1 Quote
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.