;;;; CGrid.LSP ;;;; ;;;; Ceiling grid function will draw ceiling grids on floor plan ;;;; drawings. Preview allows you to preview the grid and change ;;;; rotation and move the base point before accepting a final layout. ;;;; ;;;; Draw a polyline around the room before running this routine. ;;;; ; Copyright 1999-2001 by J. Marsden DeLapp. Based on work from Christopher Lovelock ; ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ; see http://www.fsf.org/licenses/gpl.txt ; ;;;; V1.1 3/21/01 JMD added zoom option. ;;;; V1.11 5/8/07 JMD added more clear credits to Christopher Lovelock ;;;; and released under GNU GPL. ;;;; ;;;; Some ideas where based on work from: ; (PRINC "\nGreetings from Christopher Lovelock!") ; (PRINC "\nCADenza BBS +44(0) 533 596725 U.K.") ; (PRINC "\nPCGnet 9:526/725") ; (PRINC "\nFidoNet 2:2503/308") ; (PRINC "\nCompuServe 100111,2200\n") ; "Released into the public domain 31 January 1994" (defun c:cgrid (/ areas cgXspc cgYspc change newspc pt1 pt2 rotAngl sbpt zoomopt ) (princ "\nCeiling grid v1.1 Copyright 1999-2001 by J. Marsden DeLapp. Based on work from Christopher Lovelock") (SETQ cgXspc 48.0 cgYspc 24.0 ) (princ "\nX grid spacing <") (princ cgXspc) (princ ">: ") (if (setq newspc (getreal)) (setq cgXspc newspc) ) (princ "\nY grid spacing <") (princ cgYspc) (princ ">: ") (if (setq newspc (getreal)) (setq cgYspc newspc) ) (prompt "\nSelect perimeter polyline of grid area.") (SETQ areas (SSGET)) (SETQ sbpt (GETpoint "\nSnapbase point/: ")) ;sbpt is snap base point (IF (null sbpt) (PROGN (initget 1) (setq pt1 (getpoint "\nPick first corner of the room: ")) (initget 1) (setq pt2 (getpoint "\nPick the diagonal corner: " pt1)) (setq sbpt (polar pt1 (angle pt1 pt2) (/ (distance pt1 pt2) 2.0))) ) ) (setvar "SNAPBASE" sbpt) (setvar "LASTPOINT" sbpt) (setq rotAngl (getangle sbpt "\nRotation angle: ")) (if (null rotAngl) (setq rotAngl 0.0) ) (setq rotAngl (* 180.0 (/ rotAngl PI)));convert rotation angle radians to degrees. (command ".HATCH" "U" (+ rotAngl 90.0) cgXspc "N" areas "") (command ".HATCH" "U" rotAngl cgYspc "N" areas "") (while (/= "" (setq change (strcase (getstring "\nchange Rotation, Base point, Zoom or enter to end (R,B,Z ): ")))) (cond ((= change "R") ;change rotation (setq rotAngl (getangle sbpt "\nRotation angle: ")) (setq rotAngl (* 180.0 (/ rotAngl PI)));convert rotation angle radians to degrees. (entdel (entlast));delete the previous grid before redrawing it. (entdel (entlast)) (command ".HATCH" "U" (+ rotAngl 90.0) cgXspc "N" areas "") (command ".HATCH" "U" rotAngl cgYspc "N" areas "") ) ((= change "B") ;change base point (princ "\nChange basepoint") (initget 1) (setq pt1 (getpoint "\nMove basepoint from: ")) (initget 1) (setq pt2 (getpoint "\nMove basepoint to: " pt1)) (setq sbpt (polar sbpt (angle pt1 pt2) (distance pt1 pt2))) (setvar "SNAPBASE" sbpt) (setvar "LASTPOINT" sbpt) (entdel (entlast));delete the previous grid before redrawing it. (entdel (entlast)) (command ".HATCH" "U" (+ rotAngl 90.0) cgXspc "N" areas "") (command ".HATCH" "U" rotAngl cgYspc "N" areas "") ) ((= change "Z") (initget 1 "In Out All Extents Previous Window") (setq zoomopt (getkword "\nZoom: In/Out/All/Extents/Previous/Window: ")) (if (= zoomopt "Window") (progn (initget 1) (setq pt1 (getpoint "\nFirst Corner: ")) (initget 1) (setq pt2 (getcorner "\nOpposite Corner: " pt1)) (command ".zoom" zoomopt pt1 pt2) ) (command ".zoom" zoomopt) ) ) ) ) (PRINC) ) (princ "\nCeiling grid loaded. Command is Cgrid.")