;;; ;;; ;;; ;;;"Bogus" lines may be used in the Index text file to create section headers ;;;but they must contain a tab for every column that normal lines have, ;;;(i.e., include a blank the description). ;;; ;;;> Author: Henry C. Francis ;;;> 425 N. Ashe St. ;;;> Southern Pines, NC 28387 ;;;> http://paracadd.com ;;;> All rights reserved. ;;; ;;;> COPYRIGHT: ;;;> EDITED: 12-05-2006 ;;; (defun SHTNDX_ERROR (msg / ) (IF old_shtndxerror (SETQ *ERROR* old_shtndxerror)) (IF SHTNDX_DIMSCALE (setvar "DIMSCALE" SHTNDX_DIMSCALE)) (IF SHTNDX_CMDECHO (setvar "CMDECHO" SHTNDX_CMDECHO)) (PRINC "\nERROR: ") (PRINC msg) (PRINC) ) (defun c:shtndx (/ tag_lst ndx_line red_line note_offd note_len new_len note_lst start_pt cbpt2 cbpt3 cbpt4 cnpt1 cnpt1a hdrpt1 hdrpt1a ttl_pt cnpt2 cnpt2a cccnpt3 cnpt3a cnpt4 cnpt4a cnpt5 cnpt5a cnpt6 cnpt6a cnpt7 cnpt7a cnpt8 cnpt8a cnpt9 cnpt9a cnpt10 cnpt10a note_txt str_cnt str_offd scnpt1 scnpt1a column_base ndx_file note_ofil ) (SETQ old_shtndxerror *ERROR*) (SETQ *ERROR* SHTNDX_ERROR) (setq OLD_DIMSCALE (getvar "DIMSCALE")) (setq OLD_CMDECHO (getvar "CMDECHO")) (setvar "CMDECHO" 0) (setvar "DIMSCALE" 1.0) (if (and ureal uint ustr ukword uangle udist) NIL (load "uutils") ) ;_ end of IF (setq ndx_file (getfiled "Sheet Index File" (strcat (getvar "dwgprefix") "huandx.txt") "txt" 8)) (setq wraplen (uint 1 "" "Note word wrap length" (if wraplen wraplen 50.0 ) ;_ end of if ) ;_ end of uint ) ;_ end of setq (if getstyle NIL (load "getstyle") ) ;_ end of IF (setq osmod (getvar "osmode")) (setvar "osmode" 0) (setq ;llt "-" colr "1" colra nil colri nil txtht (getvar "textsize") numb 0 modf "NOTE" ) ;_ end of SETQ (if gvpno nil (load "gvpno") ) ;_ end of if (gvpno) (if mjrg nil (setq mjrg "G") ) ;_ end of IF (if txtsize nil (load "txtsize" "\nFile TXTSIZE.LSP not found! ") ) ;_ end of if (txtsize nil) (getstyle "A") (setq colr lncolr) (c:svlayr) (command ".undo" "begin") (setq start_pt (upoint 1 "" "Pick point for upper left corner of Index" nil nil ) ;_ end of upoint ;_ end of upoint ;_ end of upoint ) ;_ end of setq (setq column_base (upoint 1 "" "Pick point for bottom of Index" nil start_pt ) ;_ end of upoint ;_ end of upoint ;_ end of upoint ) ;_ end of setq (setq col_wid (* 1.0 (/ (atof thts) 100.0))) (setq cnpt1 (polar (polar start_pt (- 0 (getvar "viewtwist")) (* 1.0 0.4 (/ (atof thts) 100.0)) ) ;_ end of polar (- 0 (getvar "viewtwist") (* pi 0.5)) (+ (* 1.0 0.65 (/ (atof thts) 100.0)) (* txtht 1 1.0)) ) ;_ end of polar cnpt1a (polar cnpt1 (- 0 (getvar "viewtwist")) (* 1.0 col_wid)) hdrpt1 (polar (polar start_pt (- 0 (getvar "viewtwist")) (* 1.0 0.4 (/ (atof thts) 100.0)) ) ;_ end of polar (- 0 (getvar "viewtwist") (* pi 0.5)) (* 1.0 0.43 (/ (atof thts) 100.0)) ) ;_ end of polar hdrpt1a (polar hdrpt1 (- 0 (getvar "viewtwist")) (* 1.0 col_wid)) ) ;_ end of setq (if ndx_file (setq note_ofil (open ndx_file "r")) (SETQ note_ofil (open (findfile "huandx.txt") "r")) ) (while (and note_ofil (setq ndx_line (read-line note_ofil)) (wcmatch (strcase ndx_line) "*DWG*") ) ;_ end of AND (while (and (/= (substr ndx_line 1 1) "\t") (/= (substr ndx_line 1 1) "\\") ) ;_ end of and (setq ndx_line (substr ndx_line 2)) ) ;_ end of while (setq strstep 2) (while (and (/= (substr ndx_line strstep 1) "\t") (/= (substr ndx_line strstep 1) "\\") ) ;_ end of and (setq strstep (1+ strstep)) ) ;_ end of while (setq vpstep (1+ strstep)) (if (or (wcmatch (substr ndx_line vpstep) "*\t*" ) ;_ end of wcmatch (wcmatch (substr ndx_line vpstep) "*\\*" ) ;_ end of wcmatch ) ;_ end of or (progn (while (and (/= (substr ndx_line vpstep 1) "\t") (/= (substr ndx_line vpstep 1) "\\") ) ;_ end of and (setq vpstep (1+ vpstep) ) ;_ end of setq ) ;_ end of while (setq sht_no (strcase (substr ndx_line 2 (- strstep 2))) vp_line (substr ndx_line (1+ vpstep)) ndx_line (strcase (substr ndx_line (1+ strstep) (- vpstep strstep 1)) ) ;_ end of strcase ) ;_ end of setq ) ;_ end of progn (setq sht_no (strcase (substr ndx_line 2 (- strstep 2))) ndx_line (strcase (substr ndx_line (1+ strstep))) ) ;_ end of setq ) ;_ end of if (if note_lst (setq note_lst (append note_lst (list (cons sht_no ndx_line)) ) ;_ end of append ) ;_ end of setq (setq note_lst (list (cons sht_no ndx_line))) ) ;_ end of if ) ;_ end of while (if note_ofil (progn (close note_ofil) (setq cnt 1) (setq shtndx_ss (ssadd)) (column_headings) (setq cnt 2 ) ;_ end of setq (setq llt "-" colr txcolr modf "NOTE" ) ;_ end of setq (c:mklayr) (foreach n note_lst (set (read (strcat "cnpt" (itoa cnt))) (polar (eval (read (strcat "cnpt" (itoa (1- cnt))))) (- 0 (getvar "viewtwist") (* pi 0.5)) (* 1.0 0.22 (/ (atof thts) 100.0)) ) ;_ end of polar ) ;_ end of set (set (read (strcat "cnpt" (itoa cnt) "a")) (polar (eval (read (strcat "cnpt" (itoa (1- cnt)) "a"))) (- 0 (getvar "viewtwist") (* pi 0.5)) (* 1.0 0.22 (/ (atof thts) 100.0)) ) ;_ end of polar ) ;_ end of set (setq cnt (1+ cnt) ) ;_ end of setq ) ;_ end of foreach (setq cnt 1 horzoffd 0.0 start_pt2 start_pt ) ;_ end of setq (foreach n note_lst (if (< (distance start_pt column_base) (distance start_pt2 (polar (polar (eval (read (strcat "cnpt" (itoa cnt)))) (- 0 (getvar "viewtwist") (* pi 0.5)) (if note_offd note_offd 0 ) ;_ end of if ) ;_ end of polar (- 0 (getvar "viewtwist")) horzoffd ) ;_ end of polar ) ;_ end of distance ) ;_ end of < (progn (setq note_offd (- (distance (eval (read (strcat "cnpt" (itoa cnt)))) cnpt1 ) ;_ end of DISTANCE ) ;_ end of - str_offd 0.0 horzoffd (+ horzoffd (distance cnpt1 cnpt1a) (* 1.0 0.25) (* 1.0 wraplen (/ (atof thts) 1000.0)) ) ;_ end of + start_pt2 (polar start_pt (- 0 (getvar "viewtwist")) horzoffd ) ;_ end of polar ) ;_ end of setq (column_headings) ) ;_ end of progn ) ;_ end of if (setq ntxt_pt1 (polar (polar (eval (read (strcat "cnpt" (itoa cnt)))) (- 0 (getvar "viewtwist") (* pi 0.5)) (if note_offd note_offd 0 ) ;_ end of if ) ;_ end of polar (- 0 (getvar "viewtwist")) horzoffd ) ;_ end of polar ) ;_ end of setq (command ".text" "j" "ml" ntxt_pt1 (* txtht 1.0) (* (/ (- 0 (getvar "viewtwist")) pi) 180) (car n) ) ;_ end of command (ssadd (entlast) shtndx_ss) (setq note_txt (cdr n)) (ndxbrkstr note_txt wraplen) (setq str_cnt 1) (repeat var_indx (setq str_offd (* (1- str_cnt) (* 1.5 txtht 1.0))) (setq ntxt_pt2 (polar (polar (eval (read (strcat "cnpt" (itoa cnt) "a"))) (- 0 (getvar "viewtwist") (* pi 0.5)) (if note_offd (+ note_offd str_offd) str_offd ) ;_ end of if ) ;_ end of polar (- 0 (getvar "viewtwist")) horzoffd ) ;_ end of polar ) ;_ end of setq (command ".text" "j" "ml" ntxt_pt2 (* txtht 1.0) (* (/ (- 0 (getvar "viewtwist")) pi) 180) (eval (read (strcat "typ_t" (itoa str_cnt)))) ) ;_ end of command (ssadd (entlast) shtndx_ss) (setq str_cnt (1+ str_cnt)) (if note_len (if (> (setq new_len (distance (car (textbox (entget (entlast)))) (cadr (textbox (entget (entlast)))) ) ;_ end of DISTANCE ) ;_ end of setq note_len ) ;_ end of > (setq note_len new_len) ) ;_ end of if (setq note_len (distance (car (textbox (entget (entlast)))) (cadr (textbox (entget (entlast)))) ) ;_ end of DISTANCE ) ;_ end of setq ) ;_ end of if ) ;_ end of repeat (if note_offd (setq note_offd (+ note_offd (* 1.5 txtht))) (setq note_offd (* 1.5 txtht)) ) ;_ end of if (setq cnt (1+ cnt) box_botm (polar (cdr (assoc 10 (entget (entlast)))) (- 0 (getvar "viewtwist") (* pi 0.5)) (* txtht 1.5) ) ;_ end of polar ) ;_ end of setq ) ;_ end of foreach (setq cbpt2 (polar start_pt (- 0 (getvar "viewtwist")) (+ (* 1.0 1.5875) note_len) ) ;_ end of polar tmp_pt1 (polar cbpt2 (- 0 (getvar "viewtwist") (* pi 0.5)) 10) tmp_pt2 (polar box_botm (- 0 (getvar "viewtwist")) 10) cbpt3 (inters cbpt2 tmp_pt1 box_botm tmp_pt2 nil) cbpt4 (polar cbpt3 (angle cbpt2 start_pt) (+ (* 1.0 1.5875) note_len) ) ;_ end of polar ttl_pt (polar (polar start_pt (- 0 (getvar "viewtwist")) (/ (+ (distance oldhdrpt1 oldhdrpt1a) (* 1.0 0.25) (* 0.1 (/ (atof thts) 100.0)) (* 1.0 wraplen (/ (atof thts) 1000.0)) (distance start_pt start_pt2) ) ;_ end of + 2 ) ;_ end of / ) ;_ end of polar (- 0 (getvar "viewtwist") (* pi 0.5)) 0 ) ;_ end of polar ) ;_ end of setq (setq colr "2") (c:mklayr) (command ".text" "j" "c" ttl_pt (* txtht 1.8) (* (/ (- 0 (getvar "viewtwist")) pi) 180) "INDEX OF SHEETS" ) ;_ end of command (ssadd (entlast) shtndx_ss) (command ".line" (polar start_pt (- 0 (getvar "viewtwist") (* pi 0.5)) (* 0.1 (/ (atof thts) 100.0)) ) ;_ end of POLAR (polar (polar start_pt (- 0 (getvar "viewtwist")) (+ (distance oldhdrpt1 oldhdrpt1a) (* 1.0 0.25) (* 0.1 (/ (atof thts) 100.0)) (* 1.0 wraplen (/ (atof thts) 1000.0)) (distance start_pt start_pt2) ) ;_ end of + ) ;_ end of POLAR (- 0 (getvar "viewtwist") (* pi 0.5)) (* 0.1 (/ (atof thts) 100.0)) ) ;_ end of POLAR "" ) ;_ end of command (ssadd (entlast) shtndx_ss) (setq grp_name_a (rtos (fix (getvar "cdate")) 2 0) grp_name_b (substr (rtos (rem (getvar "cdate") 1) 2 8) 3) grp_name_c "_INDEX" ) ;_ end of setq (command "-group" "create" (strcat grp_name_a grp_name_b grp_name_c) "Sheet Index" shtndx_ss "" ) ;_ end of COMMAND ) ;_ end of progn (princ (strcat "\nRequired file " (getvar "dwgprefix") "HUANDX.TXT not found! " ) ;_ end of strcat ) ;_ end of princ ) ;_ end of if (command ".undo" "end") (IF old_shtndxerror (SETQ *ERROR* old_shtndxerror)) (IF SHTNDX_DIMSCALE (setvar "DIMSCALE" SHTNDX_DIMSCALE)) (IF SHTNDX_CMDECHO (setvar "CMDECHO" SHTNDX_CMDECHO)) (c:rslayr) (clr_txt) (princ) ) ;_ end of defun (defun ndxbrkstr (note wrap /) (progn (setq chr_indx 1 var_indx 1 ) ;_ end of setq (setq nxt_char (substr note chr_indx 1)) (while (and (not note_done) (not (eq "" note))) (if (eq nxt_char " ") ;if breakpoint (progn (if lst_break (setq fst_break lst_break) ) ;_ end of if (setq lst_break chr_indx) ) ;_ end of progn ) ;_ end of if (if (eq nxt_char "") ;if endpoint (progn (if lst_break (setq fst_break lst_break) ) ;_ end of if (setq lst_break chr_indx done_note t ) ;_ end of setq ) ;_ end of progn ) ;_ end of if (cond ((> lst_break wrap) (set (read (strcat "typ_t" (itoa var_indx))) (substr note 1 (1- fst_break)) ) ;_ end of set (setq note (substr note (1+ fst_break)) chr_indx 1 var_indx (1+ var_indx) fst_break nil lst_break nil nxt_char (substr note 1 1) ) ;_ end of setq ) ((eq lst_break wrap) ;if 2nd break = wrap length (set (read (strcat "typ_t" (itoa var_indx))) (substr note 1 (1- lst_break)) ) ;_ end of set (if (> (strlen note) wrap) (setq note (substr note (1+ lst_break)) chr_indx 1 var_indx (1+ var_indx) fst_break nil lst_break nil nxt_char (substr note 1 1) ) ;_ end of setq (setq nxt_char "" note_done t ) ;_ end of setq ) ;_ end of if ) ((<= (strlen note) wrap) (set (read (strcat "typ_t" (itoa var_indx))) note ) ;_ end of set (setq nxt_char "" note_done t ) ;_ end of setq ) ;_ end of cond ) ;_ end of cond (setq chr_indx (1+ chr_indx) nxt_char (substr note chr_indx 1) ) ;_ end of setq ) ;_ end of while (if note_done (setq note_done nil) (progn (set (read (strcat "typ_t" (itoa var_indx))) note ) ;_ end of set ) ;_ end of progn ) ;_ end of if ) ;_ end of progn ) ;_ end of defun (defun clr_txt () (setq typ_t1 nil typ_t2 nil typ_t3 nil typ_t4 nil typ_t5 nil typ_t6 nil typ_t7 nil typ_t8 nil typ_t9 nil typ_t10 nil fst_break nil lst_break nil ) ;_ end of setq ) ;_ end of defun (defun column_headings () (setq llt "-" colr "4" modf "NOTE" ) ;_ end of setq (c:mklayr) (command ".text" "j" "ml" (POLAR hdrpt1 (+ PI(- 0 (GETVAR "VIEWTWIST"))) (* txtht 2.0)) (* txtht 1.27) (* (/ (- 0 (getvar "viewtwist")) pi) 180) "SHEET NO." ) ;_ end of command (ssadd (entlast) shtndx_ss) (command ".text" "j" "ml" hdrpt1a (* txtht 1.27) (* (/ (- 0 (getvar "viewtwist")) pi) 180) "TITLE" ) ;_ end of command (ssadd (entlast) shtndx_ss) (setq oldhdrpt1 hdrpt1 oldhdrpt1a hdrpt1a hdrpt1 (polar hdrpt1 (- 0 (getvar "viewtwist")) (+ (distance oldhdrpt1 oldhdrpt1a) (* 1.0 0.25) (* 1.0 wraplen (/ (atof thts) 1000.0)) ) ;_ end of + ) ;_ end of polar hdrpt1a (polar hdrpt1a (- 0 (getvar "viewtwist")) (+ (distance oldhdrpt1 oldhdrpt1a) (* 1.0 0.25) (* 1.0 wraplen (/ (atof thts) 1000.0)) ) ;_ end of + ) ;_ end of polar ) ;_ end of setq (setq llt "-" colr txcolr modf "NOTE" ) ;_ end of setq (c:mklayr) (princ) ) ;_ end of defun ;|«Visual LISP© Format Options» (72 2 40 2 T "end of " 60 9 1 0 0 T T nil T) ***Don't add text below the comment!***|;