;;;Draws Hiding Handrail ;;; ;;;Requires: MKLAYR.LSP, UUTILS.LSP ;;;Hiding requires: HDCIRC.DWG, HDBOX.DWG, 1X1.BMP ;;; ;;; AUTHOR: HENRY C. FRANCIS ;;; 425 N. ASHE ST. ;;; SOUTHERN PINES, NC 28387 ;;; ;;; All rights reserved without prejudice. ;;; Copyright: 8-22-96 ;;; Edited: 6-12-2003 ;;; (DEFUN c:hrail (/ made_some_lines) (SETQ old_error *error*) (DEFUN *error* (msg /) (SETQ tempss_len (IF temp_ss (SSLENGTH temp_ss) 0 ) ;_ end of IF tempss_cnt 0 ) ;_ end of setq (WHILE (< tempss_cnt tempss_len) (ENTDEL (SSNAME temp_ss tempss_cnt)) (SETQ tempss_cnt (1+ tempss_cnt)) ) ;_ end of while (SETQ *error* old_error) (PRINC "\n") (PRINC msg) (PRINC "\nERROR: Hrail cancelled! ") (PRINC) ) ;_ end of defun (IF c:mklayr nil (LOAD "mklayr" "\nFile MKLAYR.LSP not loaded! ") ) ;_ end of if (IF (AND ukword ureal upoint) nil (LOAD "uutils" "\nFile UUTILS.LSP not loaded! ") ) ;_ end of if (SETQ end_cond (ukword 1 "First Last Both None" "Round ends " (IF end_cond end_cond "Both" ) ;_ end of if ) ;_ end of ukword ) ;_ end of setq (SETVAR "PLINEWID" 0) (COND ((EQ end_cond "First") (SETQ arc_end1 T arc_end2 nil ) ;_ end of setq ) ((EQ end_cond "Last") (SETQ arc_end1 nil arc_end2 T ) ;_ end of setq ) ((EQ end_cond "Both") (SETQ arc_end1 T arc_end2 T ) ;_ end of setq ) ((EQ end_cond "None") (SETQ arc_end1 nil arc_end2 nil ) ;_ end of setq ) ) ;cond (SETQ rail_od (ureal 0 "" "Handrail O.D.: " (IF rail_od rail_od 1.9 ) ;_ end of if ) ;_ end of ureal ) ;_ end of setq (SETQ rail_hd (/ rail_od 2.0)) (SETQ hr_pnt_lst nil) (SETQ temp_ss (SSADD)) (WHILE (SETQ nxt_hr_pnt (upoint 0 "" "Pick handrail points" nil (IF nxt_hr_pnt nxt_hr_pnt ) ;_ end of if ) ;_ end of upoint ) ;_ end of setq (SETQ hr_pnt_lst (APPEND hr_pnt_lst (LIST (LIST (CAR nxt_hr_pnt) (CADR nxt_hr_pnt) (GETVAR "elevation"))))) (IF (> (LENGTH hr_pnt_lst) 1) (PROGN (IF (ENTMAKE (LIST (CONS 0 "line");create temporary lines so user can see points picked even after a redraw or zoom (CONS 8 "temp-hrail") (CONS 10 (CADR (REVERSE hr_pnt_lst))) (CONS 11 (CAR (REVERSE hr_pnt_lst))) ) ;_ end of LIST ) ;_ end of entmake (PROGN (SSADD (ENTLAST) temp_ss) (SETQ made_some_lines T)) ) ;_ end of IF ) ;_ end of progn ) ;_ end of if ) ;_ end of while (IF (> (LENGTH hr_pnt_lst) 1) (PROGN (IF (TBLOBJNAME "block" "hdcirc") nil (IF (FINDFILE "hdcirc.dwg") (PROGN (COMMAND ".-insert" "hdcirc") (COMMAND));define block "hdcirc" ) ;_ end of progn ) ;_ end of IF (IF (TBLOBJNAME "block" "hdbox") nil (IF (FINDFILE "hdbox.dwg") (PROGN (COMMAND ".-insert" "hdbox") (COMMAND));define block "hdbox" ) ;_ end of progn ) ;_ end of IF (SETQ hrail_ss (SSADD)) (IF mjrg nil (SETQ mjrg "M") ) ;_ end of if (IF llt nil (SETQ llt "-") ) ;_ end of if (IF prod nil (SETQ prod "RAIL") ) ;_ end of if (IF (OR (AND colri colra) colr) nil (SETQ colr "1" colri nil colra nil ) ;_ end of setq ) ;_ end of if (IF modf nil (SETQ modf "HAND") ) ;_ end of if (c:svlayr) (c:mklayr) (SETQ hr_pnt_cnt 1) (WHILE (< hr_pnt_cnt (LENGTH hr_pnt_lst)) (SETQ hr_pnt1 (NTH (1- hr_pnt_cnt) hr_pnt_lst) ;rail segment first midpoint hr_pnt2 (NTH hr_pnt_cnt hr_pnt_lst) ;rail segment second midpoint (next rail first midpoint) hr_ang1 (+ (ANGLE hr_pnt1 hr_pnt2) (* PI 0.5));perpindicular angle left hr_ang2 (+ (ANGLE hr_pnt1 hr_pnt2) (* PI 1.5));perpindicular angle right hr_pntl1 (polar hr_pnt1 hr_ang1 rail_hd) ;left rail line first perpin. point hr_pntl2 (polar hr_pnt2 hr_ang1 rail_hd) ;left rail line second perpin. point hr_pntr1 (polar hr_pnt1 hr_ang2 rail_hd) ;right rail line first perpin. point hr_pntr2 (polar hr_pnt2 hr_ang2 rail_hd) ;right rail line second perpin. point ) ;_ end of setq (if hrll_nxt1 (setq hrll_pnt1 hrll_nxt1 hrll_nxt1 nil) ) (if hrrl_nxt1 (setq hrrl_pnt1 hrrl_nxt1 hrrl_nxt1 nil) ) (IF (< hr_pnt_cnt (1-(length hr_pnt_lst))) (PROGN (SETQ hr_nxt2 (NTH (+ hr_pnt_cnt 1) hr_pnt_lst);next rail segment second midpoint hr_nxang1 (+ (ANGLE hr_pnt2 hr_nxt2) (* PI 0.5));next rail perpin. angle left hr_nxang2 (+ (ANGLE hr_pnt2 hr_nxt2) (* PI 1.5));next rail perpin. angle right hr_nxtl1 (polar hr_pnt2 hr_nxang1 rail_hd);next left rail line first perpin. point hr_nxtl2 (polar hr_nxt2 hr_nxang1 rail_hd);next left rail line second perpin. point hr_nxtr1 (polar hr_pnt2 hr_nxang2 rail_hd);next right rail line first perpin. point hr_nxtr2 (polar hr_nxt2 hr_nxang2 rail_hd);next right rail line second perpin. point hrll_int2 (inters hr_pntl1 hr_pntl2 hr_nxtl1 hr_nxtl2 nil);left inters first/second rail hrrl_int2 (inters hr_pntr1 hr_pntr2 hr_nxtr1 hr_nxtr2 nil);right inters first/second rail ) (IF (>(distance hr_pntl1 hrll_int2)(distance hr_pntl1 hr_pntl2)) (setq hrll_pnt2 hr_pntl2 arc_endpt hr_pntl2) (setq hrll_pnt2 hrll_int2) ) (IF (>(distance hr_pntr1 hrrl_int2)(distance hr_pntr1 hr_pntr2)) (setq hrrl_pnt2 hr_pntr2 arc_begpt hr_pntr2) (setq hrrl_pnt2 hrrl_int2) ) (IF (>(distance hr_nxtl2 hrll_int2)(distance hr_nxtl2 hr_nxtl1)) (setq hrll_nxt1 hr_nxtl1 arc_begpt hr_nxtl1) (setq hrll_nxt1 hrll_int2) ) (IF (>(distance hr_nxtr2 hrrl_int2)(distance hr_nxtr2 hr_nxtr1)) (setq hrrl_nxt1 hr_nxtr1 arc_endpt hr_nxtr1) (setq hrrl_nxt1 hrrl_int2) ) ) ) (SETQ prev_colr colr colr "1" colra nil colri nil usdf "HIDE" ) ;_ end of setq (c:mklayr) (IF (AND (OR (> hr_pnt_cnt 1) arc_end1);place first and intermediate corner hiding blocks (TBLOBJNAME "block" "hdcirc") (ENTMAKE (LIST (CONS 0 "insert") (CONS 2 "hdcirc") (CONS 10 hr_pnt1) (CONS 41 rail_od) (CONS 42 rail_od) (CONS 43 rail_od) ) ;_ end of list ) ;_ end of entmake ) ;_ end of and (SSADD (ENTLAST) hrail_ss) ) ;_ end of if (IF (AND (EQ hr_pnt_cnt (1- (LENGTH hr_pnt_lst)));place last corner hiding block arc_end2 (TBLOBJNAME "block" "hdcirc") (ENTMAKE (LIST (CONS 0 "insert") (CONS 2 "hdcirc") (CONS 10 hr_pnt2) (CONS 41 rail_od) (CONS 42 rail_od) (CONS 43 rail_od) ) ;_ end of list ) ;_ end of entmake ) ;_ end of and (SSADD (ENTLAST) hrail_ss) ) ;_ end of if (IF (AND (TBLOBJNAME "block" "hdbox");place pipe handrail hiding blocks (ENTMAKE (LIST (CONS 0 "insert") (CONS 2 "hdbox") (CONS 10 (POLAR hr_pnt1 hr_ang2 rail_hd)) (CONS 41 (DISTANCE hr_pnt1 hr_pnt2)) (CONS 42 rail_od) (CONS 43 1) (CONS 50 (ANGLE hr_pnt1 hr_pnt2)) ) ;_ end of list ) ;_ end of entmake ) ;_ end of and (SSADD (ENTLAST) hrail_ss) ) ;_ end of if (SETQ colr prev_colr colra nil colri nil usdf nil ) ;_ end of setq (c:mklayr) (IF (AND (EQ hr_pnt_cnt 1) arc_end1) (IF (ENTMAKE (LIST (CONS 0 "arc") (cons 10 hr_pnt1) (cons 40 rail_hd) (cons 50 hr_ang1) (cons 51 hr_ang2) ) ) (SSADD (ENTLAST) hrail_ss) ) (IF (EQ hr_pnt_cnt 1) (IF (ENTMAKE (LIST (CONS 0 "line") (cons 10 (polar hr_pnt1 hr_ang1 rail_hd)) (cons 11 (polar hr_pnt1 hr_ang2 rail_hd)) ) ) (SSADD (ENTLAST) hrail_ss) ) ) ) (IF (< hr_pnt_cnt (1- (LENGTH hr_pnt_lst))) (IF (ENTMAKE (LIST (CONS 0 "arc") (cons 10 hr_pnt2) (cons 40 rail_hd) (cons 50 (angle hr_pnt2 arc_begpt)) (cons 51 (angle hr_pnt2 arc_endpt)) ) ) (SSADD (ENTLAST) hrail_ss))) (IF (AND (EQ hr_pnt_cnt (1- (LENGTH hr_pnt_lst))) arc_end2) (IF (ENTMAKE (LIST (CONS 0 "arc") (cons 10 hr_pnt2) (cons 40 rail_hd) (cons 50 hr_ang2) (cons 51 hr_ang1) ) ) (SSADD (ENTLAST) hrail_ss) ) (IF (EQ hr_pnt_cnt (1- (LENGTH hr_pnt_lst))) (IF (ENTMAKE (LIST (CONS 0 "line") (cons 10 (polar hr_pnt2 hr_ang1 rail_hd)) (cons 11 (polar hr_pnt2 hr_ang2 rail_hd)) ) ) (SSADD (ENTLAST) hrail_ss) ) ) ) (if (eq hr_pnt_cnt 1) (progn ;set left and right pnt1 and pnt2 for first rail (setq hrll_pnt1 (POLAR hr_pnt1 hr_ang1 rail_hd) hrrl_pnt1 (POLAR hr_pnt1 hr_ang2 rail_hd) ) ) ) ;;; (IF ;;; (and (not (eq hr_pnt_cnt 1))(not (EQ hr_pnt_cnt (1- (LENGTH hr_pnt_lst))))) ;;; (progn ;set left and right pnt1 and pnt2 for intermediate rails ;;; ) ;;; ) (IF (and (not (eq hr_pnt_cnt 1))(EQ hr_pnt_cnt (1- (LENGTH hr_pnt_lst)))) (progn ;set left and right pnt1 and pnt2 for last rail (setq hrll_pnt2 (POLAR hr_pnt2 hr_ang1 rail_hd) hrrl_pnt2 (POLAR hr_pnt2 hr_ang2 rail_hd) ) ) ) (IF (ENTMAKE (LIST (CONS 0 "line");create left line (CONS 10 hrll_pnt1) (CONS 11 hrll_pnt2) ) ;_ end of list ) ;_ end of entmake (SSADD (ENTLAST) hrail_ss) ) ;_ end of if (IF (ENTMAKE (LIST (CONS 0 "line");create right line (CONS 10 hrrl_pnt1) (CONS 11 hrrl_pnt2) ) ;_ end of list ) ;_ end of entmake (SSADD (ENTLAST) hrail_ss) ) ;_ end of if (SETQ hr_pnt_cnt (1+ hr_pnt_cnt)) ) ;_ end of while (COMMAND ".pedit" (entlast) "Y" "J" hrail_ss "" "") (SSADD (ENTLAST) hrail_ss) ) ;_ end of PROGN ) ;_ end of IF (IF (AND made_some_lines temp_ss) (PROGN (SETQ tempss_len (SSLENGTH temp_ss) tempss_cnt 0 ) ;_ end of setq (WHILE (< tempss_cnt tempss_len) (ENTDEL (SSNAME temp_ss tempss_cnt)) (SETQ tempss_cnt (1+ tempss_cnt)) ) ;_ end of while ) ;_ end of progn ) ;_ end of IF (c:rslayr) (if c:hdtext nil (load "ddhtext" "\nFile DDHTEXT.LSP not loaded! ") ) (c:hdupd) (IF (FINDFILE "1x1.bmp") (PROGN (IF (TBLOBJNAME "block" "hdcirc") nil (PROGN (PRINC "\nDrawing HDCIRC.DWG not found! Hiding corners disabled. ") (PRINC)) ) ;_ end of IF (IF (TBLOBJNAME "block" "hdbox") nil (PROGN (PRINC "\nDrawing HDBOX.DWG not found! Hiding handrail disabled. ") (PRINC)) ) ;_ end of IF ) ;_ end of PROGN (PROGN (PRINC "\nImage 1X1.BMP not found! Hiding handrail disabled. ") (PRINC)) ) ;_ end of IF (SETQ *error* old_error) (PRINC) ) ;defun ;|«Visual LISP© Format Options» (120 2 15 2 T "end of " 100 9 2 0 nil nil nil T T) ;*** DO NOT add text below the comment! ***|;