;KPL.LSP Key Pad Lines (c) 1990 ;Dan Conklin Bench Mark Land Surveying ;CIS 70270,422 Riviera Beach, Florida 33404 ; ;KEYWORDS: LINE, KEYPAD, SURVEYING, CIVIL, FEETINCH-DECFEET, GRREAD ; ;NOTE: Although this routine uses decimal feet units, it could be ;modified to work with other units. ; ;KPL uses (grread) and the numeric keypad, with the NumLock on, as a ;direction indicator for drawing lines. Also, defun FI2DF is used as an ;easy way of entering feet and inches when using decimal feet units. ; ; 7 8 9 ; \ ^ / ; 4< >6 ; / v \ ; 1 2 3 ; ;One character input (no CR or SP) is used for direction and mode selection ;even in the middle of distance input (except for Y input). ; ;One distance is entered for Equal XY and Diagonal distances and lines ;are drawn at 45 degrees. A Y distance is needed for unequal Xy diagonals. ; ;A carriage return or space at the From Point prompt starts the line ;from the second from last point (if not nil) which should be where ;to start if a bad distance is entered and the last line is erased. ; ;A carriage return or space at the KP direction prompt exits the program. ; ;A carriage return or space at a distance input uses the last distance ;if not nil or 0. ; ;This routine is useful for surveyors entering buildings into CAD ;from architectural plans for building stakeout and permit ;surveys using feet and inches, and also for form board/ slab/ ;under construction/ final tie ins of buildings using normal real ;decimal feet. It's a quick and easy way for entering the ;linework and also for adding up the building to make sure it closes. ; ;NOTE: When using a UCS the routine is very slow, but you can still ;type ahead. ;Also, don't do ctrl Q, printer won't advance. ;==================================================================== (Defun *error* (st) (prompt "Error: ") (prompt st) (terpri) ) (Defun C:KPL () ; ;Global Var: ;KPdist = Key Pad distance mode (dec. feet or feet inch) ;EDXY = Equal, Diagonal, or different Xy mode for diagonals ;FP2Las = Second from last point of key pad lines ;LasDis = Last Distance of key pad lines ;FP, TP = From Point, To Point ;KeyDir = Key Direction "1" to "9" (no "5")) ;DisStr = Distance String ;adist = real distance ;ydist = real distance ; (Setvar "Cmdecho" 0) (if (= KPdist nil) (setq KPdist "N")) (if (= EDXY nil) (setq EDXY "E")) (if (= FP2Las nil) (setq FP2Las (Getvar "LASTPOINT"))) (if (= LasDis nil) (setq LasDis (Getvar "DISTANCE" ))) (Setq FP (Getpoint "\nFrom Point <2ndLastPt>: ")) (prompt "\n") (if (= FP nil) (Setq FP FP2Las)) ; (while (KPdir) (progn (prompt "\n") (Dinp) (prompt "\n")) ; (if (= KPdist "F") (setq adist (FI2DF DisStr)) (setq adist (atof DisStr))) (if (= EDXY "X") (progn (if (member KeyDir '("9" "3" "1" "7")) (progn (cond ((= KPdist "F") (setq ydist (FI2DF (getstring "Enter Y Distance: ")))) ((= KPdist "N") (setq ydist (getdist "Enter Y Distance: ")))))))) (cond ((= EDXY "E") (setq ydist adist)) ((= EDXY "D") (if (or (= KeyDir "2") (= KeyDir "4") (= KeyDir "6") (= KeyDir "8")) (setq ydist adist) (setq adist (* adist (/ (sqrt 2.0) 2.0)) ydist adist))) ) (if (or (= adist nil) (= adist 0.0)) (setq adist LasDis)) (if (or (= ydist nil) (= ydist 0.0)) (setq ydist LasDis)) (cond ((= KeyDir "8") (Setq TP (List (Car FP) (+ (Cadr FP) adist)))) ((= KeyDir "6") (Setq TP (List (+ (Car FP) adist) (Cadr FP)))) ((= KeyDir "2") (Setq TP (List (Car FP) (- (Cadr FP) ydist)))) ((= KeyDir "4") (Setq TP (List (- (Car FP) adist) (Cadr FP)))) ((= KeyDir "9") (Setq TP (List (+ (Car FP) adist) (+ (Cadr FP) ydist)))) ((= KeyDir "3") (Setq TP (List (+ (Car FP) adist) (- (Cadr FP) ydist)))) ((= KeyDir "1") (Setq TP (List (- (Car FP) adist) (- (Cadr FP) ydist)))) ((= KeyDir "7") (Setq TP (List (- (Car FP) adist) (+ (Cadr FP) ydist)))) ) (Command "Line" FP TP "") (Setq FP2Las FP FP TP LasDis adist) )(princ)) ;==================================================================== (Defun KPdir( / KeyCh oklist ) (setq KeyCh "") (prompt (strcat "\r" (Msg1) "KeyPad Direction: ")) (setq oklist '( "7" "8" "9" "4" "6" "1" "2" "3" "N" "F" "E" "D" "X" "n" "f" "e" "d" "x")) (setq KeyCh (getch oklist )) (cond ((= KeyCh "8") (prompt "^" ) (setq KeyDir "8")) ((= KeyCh "6") (prompt ">" ) (setq KeyDir "6")) ((= KeyCh "2") (prompt "v" ) (setq KeyDir "2")) ((= KeyCh "4") (prompt "<" ) (setq KeyDir "4")) ((= KeyCh "9") (prompt "^/" ) (setq KeyDir "9")) ((= KeyCh "3") (prompt "v\\") (setq KeyDir "3")) ((= KeyCh "1") (prompt "v/" ) (setq KeyDir "1")) ((= KeyCh "7") (prompt "^\\") (setq KeyDir "7")) ;((= KeyCh "5") (prompt "+") (SetEl) (KPdir)) ;((= KeyCh "+") (prompt "+") (SetEl) (KPdir)) ((or(= KeyCh "F")(= KeyCh "f")) (setq KPdist "F") (Kpdir)) ((or(= KeyCh "N")(= KeyCh "n")) (setq KPdist "N") (Kpdir)) ((or(= KeyCh "D")(= KeyCh "d")) (setq EDXY "D") (Kpdir)) ((or(= KeyCh "E")(= KeyCh "e")) (setq EDXY "E") (Kpdir)) ((or(= KeyCh "X")(= KeyCh "x")) (setq EDXY "X") (Kpdir)) ; ((= KeyCh "CrSp") ;exit ) (t nil) ) ) ;==================================================================== (Defun Dinp( / KeyCh oklist) (setq KeyCh "") (setq DisStr "") (while (/= KeyCh "CrSp") (prompt (strcat "\r" (Msg1) "Enter Distance : " DisStr " ")) (setq oklist '( "7" "8" "9" "4" "5" "6" "1" "2" "3" "0" "." "N" "F" "E" "D" "X" "n" "f" "e" "d" "x")) (setq KeyCh (getch oklist)) (cond ((member KeyCh '( "7" "8" "9" "4" "5" "6" "1" "2" "3" "0" ".")) (setq DisStr (strcat DisStr KeyCh))) ;((= KeyCh "+") (prompt "+") (SetEl) (KPdir)) ((or(= KeyCh "F")(= KeyCh "f")) (setq KPdist "F")) ((or(= KeyCh "N")(= KeyCh "n")) (setq KPdist "N")) ((or(= KeyCh "D")(= KeyCh "d")) (setq EDXY "D")) ((or(= KeyCh "E")(= KeyCh "e")) (setq EDXY "E")) ((or(= KeyCh "X")(= KeyCh "x")) (setq EDXY "X")) ((= KeyCh "Bksp")(setq DisStr (substr DisStr 1 (- (strlen DisStr) 1)))) (t nil) )) ) ;==================================================================== (Defun Msg1(/ Str1 Str2) (cond ((= KPdist "N") (setq Str1 "/Ft.in.din.frac ")) ((= KPdist "F") (setq Str1 "Normal/ ")) (T nil)) (cond ((= EDXY "E") (setq Str2 "/Diagonal/Xy ")) ((= EDXY "D") (setq Str2 "Equalxy//Xy ")) ((= EDXY "X") (setq Str2 "Equalxy/Diagonal/ ")) (T nil)) (strcat Str1 Str2) ) ;==================================================================== (Defun getch (oklist / TypInp Inp GoodCh ch) (setq TypInp (car (setq Inp (grread)))) (if (= TypInp 2) (progn (setq GoodCh (chr (cadr Inp))) (cond ((member GoodCh oklist) (setq ch GoodCh)) ((or (= GoodCh (chr 13)) (= GoodCh (chr 32))) (setq ch "CrSp")) ( (= GoodCh (chr 08)) (setq ch "Bksp")) ( (= GoodCh (chr 27)) (setq ch "Esc" )) (t (getch oklist))) ) (setq ch "NotKB")) ) ;==================================================================== ;MENU PICK ==>>[FtIn 2 DecFt]^P(FI2DF (getstring " Enter Ft.in.din.frac ")) ; ;For entering distances in feet and inches when using decimal feet units ; (Defun FI2DF (Ftin / DecFt Ndp Pdp1 Cnt Ft Inch DInch Tfrac Bfrac) ; ; No trailing decimals points allowed ; Maximum 3 decimal points ; Ndp = Number of decimal points ; Pdp1 = Position of decimal point one ; ; example distance | input | Ndp | description ;------------------|---------|-----|------------- ; 12' | 12 | 0 | whole feet ; 2'-3" | 2.3 | 1 | Ft-inch ; 8'-10.5" | 8.10.5 | 2 | Ft-dec-inch ; 5'-9 7/8" | 5.9.7.8 | 3 | Ft-frac-inch ; (setq Cnt 1) (setq Ndp 0) (repeat (strlen Ftin) (if (= (substr Ftin Cnt 1) (chr 46)) (cond ((= Ndp 0) (setq Ndp 1) (setq Pdp1 Cnt)) ((= Ndp 1) (setq Ndp 2) (setq Pdp2 Cnt)) ((= Ndp 2) (setq Ndp 3) (setq Pdp3 Cnt)) ) ) (setq Cnt (1+ Cnt)) ) (cond ((= Ndp 0) (setq DecFt (atof Ftin))) ((= Ndp 1) (setq Ft (substr Ftin 1 (1- Pdp1)) Inch (substr Ftin (1+ Pdp1) ) DecFt (+ (atof Ft) (/ (atof Inch) 12.0)))) ((= Ndp 2) (setq Ft (substr Ftin 1 (1- Pdp1)) DInch (substr Ftin (1+ Pdp1) ) DecFt (+ (atof Ft) (/ (atof Dinch) 12.0)))) ((= Ndp 3) (setq Ft (substr Ftin 1 (1- Pdp1)) Inch (substr Ftin (1+ Pdp1) (- Pdp2 Pdp1 1)) Tfrac (substr Ftin (1+ Pdp2) (- Pdp3 Pdp2 1)) Bfrac (substr Ftin (1+ Pdp3) ) DecFt (+ (atof Ft) (/ (+ (atof Inch) (/ (atof Tfrac) (atof Bfrac))) 12.0))))) )