; TIP1108.LSP: SWL.LSP Stone Wall (c)1995, Robert A. Perruzzi ; A LISP routine which draws a stone wall over a line, on the ; current layer. Uses an angled array so that individual stones ; can be removed or changed. This is the basis for some other LISP : routines which draw retaining walls, treelines ans railroad tracks. ; GET VARIABLES (defun modes (A) (setq MLST '()) (repeat (length A) (setq MLST (append MLST (list (list (car A) (getvar (car A)))))) (setq A (cdr A))) ) ; (defun MODER () (repeat (length MLST) (setvar (caar MLST) (cadar MLST)) (setq MLST (cdr MLST)) ) ) ; (defun swerror (st) ; If an error (such as CTRL-C) occurs ; while this command is active... (if (/= ST "Function cancelled") (princ (strcat "\nError: " ST)) ) (moder) ; Restore modified modes (setq *error* OLDERR) ; Restore old *error* handler (princ) ) ; (defun swuser ( / SEX C B TEST) (graphscr) ;; (setq SEX (entsel "\nPick LINE to change: "))(terpri) (setq B (entget (car sex))) (setq TEST 1) (while TEST (setq B (cdr B)) (if (= 10 (car (car B))) (setq TEST nil) ) ) (setq SP (car B)) (setq SP (cdr SP)) (setq C (entget (car SEX))) (setq TEST 1) (while TEST (setq C (cdr C)) (if (= 11 (car (car C))) (setq TEST nil) ) ) (setq EP (car C)) (setq EP (cdr EP)) ; (if (> (car SP) (car EP)) (progn (setq TP SP) (setq SP EP) (setq EP TP) ) ) (setq WANGLE (angle SP EP)) (setq TEMP WSIZE) (if (null TEMP)(setq TEMP 0.125)) (princ "\nSize of Each Stone:")(princ '<)(princ temp)(princ '>) (setq WSIZE (getdist)) (if (null WSIZE)(setq WSIZE TEMP)) (setq WLENGTH (distance SP EP)) (setq NUMB (/ WLENGTH WSIZE)) (setq BASE (/ WLENGTH (fix NUMB))) (setq SCSIZE (/ BASE 0.125)) ) ; Draw wall (defun drawstn () (command "insert" "stone.dwg" SP SCSIZE SCSIZE WANGLE);; revise directory to suit ) ; Change snap rotation to wall angle (defun wsnap () (command "snap" "r" "0,0" WANGLE) ) ; Draw rest of wall (defun drawsw () (setq result (command "array" "l" "" "r" "1" (fix NUMB) BASE)) (princ result) ) ; Main program execution (defun C:SWL () (setq OLDERR *error* *error* SWERROR) (modes '("BLIPMODE" "CMDECHO" "AUNITS" "ANGBASE" "ANGDIR" "SNAPANG" "SNAPMODE" )) ; (setvar "BLIPMODE" 0) ; make (setvar "CMDECHO" 0) ; all (setvar "AUNITS" 3) ; settings (setvar "ANGBASE" 0) ; zero (setvar "ANGDIR" 0) ; (swuser) (drawstn) (wsnap) (drawsw) ; (moder) ; Restore modified modes (setq *error* OLDERR) ; Restore old *error* handler (princ) ); end swl.lsp