;| MRP.Lsp - Multiple Rotate by Point Description: Rotates, by reference angle, multiple blocks toward a specified point or saved View's camera point. You can select blocks by Selection set or by Layer filtering. Useful in renderings when you need to rotate bitmap people toward a camera source. Requested routine by Ernesto Lacalle. Requested updates 1.4 & 1.5 by Tim Dougherty. ------------------------------------------------------------------------ ------------------------------------------------------------------------ Created by J. Tippit, SPAUG President E-mail: jefft@iglobal.net Web Site: http://www.spaug.org Large donations to SPAUG is appreciated. :) ------------------------------------------------------------------------ ------------------------------------------------------------------------ Revisions: 1.0 Originally created 08/03/99 1.1 Added Layer filtering 08/10/99 1.2 Added View option 08/17/99 1.3 Revised calculation for finding the Camera point 08/18/99 1.4 Added angle entry prompt 11/06/00 1.5 Added text,mtext,rtext,attdef support 12/10/00 |; ;---------------------------------------------------------------------- ; Error Handler ;---------------------------------------------------------------------- (defun mrperr (s) (if (not (member s '("console break" "Function cancelled"))) (princ (strcat "\nError: " s "\nResetting Variables.")) ) (command "._ucs" "_p") (setvar "osmode" os) (command "._undo" "_e") (setvar "cmdecho" 1) (setq *error* mrpolderr) (princ) ) (defun C:MRP (/ MRP_S MRP_L MRP_C MRP_CNT MRP_E MRP_P MRP_A MRP_FLB MRP_SL MRP_LN MRP_POV MRP_TVN MRP_TB) (setq mrpolderr *error* *error* mrperr) (setvar "cmdecho" 0) (command "._undo" "_be") (command "._ucs" "") (setq os (getvar "osmode")) (setvar "osmode" 0) ;;; added prompt for BLOCK or TEXT (initget "T B") (setq MRP_TB (getkword "\nFilter by locks or ext Entities? : ")) (if (= MRP_TB nil)(setq MRP_TB "B")) ;;; (initget "Y N") (setq MRP_FBL (getkword "\nFilter by Layer? : ")) (if (= MRP_FBL "Y") (progn (while (not MRP_SL) (setq MRP_SL (entsel "\nSelect an entity that is on the layer you want to filter by: ")) (if (= MRP_SL nil) (princ "\nMissed. Try again...\n") ) ) (setq MRP_LN (cdr (assoc 8 (entget (car MRP_SL))))) (if (= MRP_TB "B") (setq MRP_S (ssget "X" (list (cons 0 "INSERT")(cons 8 MRP_LN)))) (setq MRP_S (ssget "X" (list '(0 . "TEXT,MTEXT,RTEXT,ATTDEF")(cons 8 mrp_ln)))) ) ) (progn (if (= MRP_TB "B") (progn (prompt "\nNOTE:Window area containing BLOCKS...all other entities will be filtered out ") (setq MRP_S (ssget '((0 . "INSERT")))) ) (progn (setq MRP_S (ssget '((-4 . "")))) ) ) ) ) (setq MRP_L (sslength MRP_S)) (initget "P V") (setq MRP_POV (getkword "\n

ick a Point or iew?

: ")) (if (= MRP_POV "V") (progn (while (not MRP_TVN) (setq MRP_VWN (getstring "\nType the VIEW name: ")) (setq MRP_TVN (tblsearch "VIEW" MRP_VWN)) (if (= MRP_TVN nil) (princ "\nNo matching VIEW name found! Try again...\n") ) ) (setq MRP_10 (cdr (assoc 10 MRP_TVN)));center point (setq MRP_11 (cdr (assoc 11 MRP_TVN)));distance vector point from center (setq MRP_12 (cdr (assoc 12 MRP_TVN)));target point (setq MRP_1A (angle MRP_10 MRP_11)) (setq MRP_1D (distance MRP_10 MRP_11)) (setq MRP_C (polar MRP_12 MRP_1A MRP_1D));find camera point ) (setq MRP_C (getpoint "\nPick a point to rotate blocks toward: ")) ) ;;; added prompt for angle entry (if (= MRP_ROT nil)(setq MRP_ROT 0.0)) (setq MRP_ROT2 MRP_ROT) (setq MRP_ROT (getdist (strcat "\nEnter Rotation Angle [clockwise] <" (rtos MRP_ROT 2) ">: "))) (if (= MRP_ROT nil)(setq MRP_ROT MRP_ROT2)) ;;; (setq MRP_CNT 0) (while (< MRP_CNT MRP_L) (setq MRP_E (entget (ssname MRP_S MRP_CNT))) (setq MRP_P (cdr (assoc 10 MRP_E))) (setq MRP_A (- (+ (/ (* (cdr (assoc 50 MRP_E)) 180.0) pi) MRP_ROT) 180.0)); revised for angle entry (command "._rotate" (ssname MRP_S MRP_CNT) "" MRP_P "_r" MRP_A (/ (* (angle MRP_C MRP_P) 180.0) pi)) (setq MRP_CNT (1+ MRP_CNT)) ) (command "._ucs" "_p") (setvar "osmode" os) (command "._undo" "_e") (setvar "cmdecho" 1) (setq *error* mrpolderr) (princ) ) (prompt (strcat "\nCopyright \251 TCS 1999-2000 Version 1.5 - MRP loaded.")) (prompt "\nType MRP to Run.") (princ)