;;;Convert layer names to Standard CLG (as modified for color and linetype). (PER OUR STANDARD) ;;; ;;; ;;; ;;;> Author: Henry C. Francis ;;;> 425 N. Ashe St. ;;;> Southern Pines, NC 28387 ;;;> http://paracadd.com ;;;> All rights reserved. ;;; ;;;> COPYRIGHT: 2-6-96 ;;;> EDITED: 06-30-2006 ;;; (DEFUN c:stdlayr (/ clayr lname rlnm z chglss clssln cntr edlanm lay_list) (SETQ rg_mode (GETVAR "regenmode")) (SETQ cmd_echo (GETVAR "cmdecho")) (SETVAR "regenmode" 0) (SETVAR "cmdecho" 0) (IF mklayr nil (LOAD "mklayr") ) ;_ end of IF (laylst) (rnlay) (SETQ lay_list (SUBST "0" nil lay_list)) (FOREACH clayr lay_list ; (IF ; clayr (IF (clnmstd) (PRINC (STRCAT "\n" clayr " is a standard layer name")) ;if standard do this ;if non-standard and not an xref layer name do this (IF (OR (= (CDR (ASSOC 70 (TBLSEARCH "layer" clayr))) 16) (= (CDR (ASSOC 70 (TBLSEARCH "layer" clayr))) 32) (= (CDR (ASSOC 70 (TBLSEARCH "layer" clayr))) 48) (= (CDR (ASSOC 70 (TBLSEARCH "layer" clayr))) 112) (= (CDR (ASSOC 2 (TBLSEARCH "layer" clayr))) "0") (= (CDR (ASSOC 2 (TBLSEARCH "layer" clayr))) "DEFPOINTS") (= (CDR (ASSOC 2 (TBLSEARCH "layer" clayr))) "DESC") (= (CDR (ASSOC 2 (TBLSEARCH "layer" clayr))) "ELEV") (= (CDR (ASSOC 2 (TBLSEARCH "layer" clayr))) "PNTS") (= (CDR (ASSOC 2 (TBLSEARCH "layer" clayr))) "DWGSTAMP") (= (CDR (ASSOC 2 (TBLSEARCH "layer" clayr))) "DCA_INFO") ) ;_ end of or (PRINC (STRCAT "\nLayer " clayr " will not be renamed")) (PROGN (SETQ lelst (TBLSEARCH "layer" clayr)) (SETQ lltyp (CDR (ASSOC 6 lelst))) (SETQ lcolr (CDR (ASSOC 62 lelst))) (getdefs) ; (princ (strcat "\n" clayr " is not on rrlst, it will be added")) (IF ustr NIL (LOAD "ustr" "\nFile USTR.LSP not loaded! ") ) ;_ end of IF (SETQ rlnm (ustr 1 (STRCAT "\nEnter new name for layer " clayr " or * to keep it." ) ;_ end of strcat nlndef nil ) ;_ end of ustr ) ;_ end of setq (IF (EQ rlnm "*") nil (PROGN (SETQ rnlay_dat (OPEN "H:/UTIL/LSP/RNLAY.DAT" "a")) (WRITE-LINE (STRCASE clayr) rnlay_dat) (WRITE-LINE (STRCASE rlnm T) rnlay_dat) (WRITE-LINE (STRCASE rn_ltyp T) rnlay_dat) (SETQ rn_colr (SUBSTR rlnm 7 1)) (IF (= (ATOI rn_colr) 0) (SETQ rn_colr "1") ) ;_ end of IF (COND ((= rn_colr "A") (SETQ rn_colr "10")) ((= rn_colr "B") (SETQ rn_colr "11")) ((= rn_colr "C") (SETQ rn_colr "12")) ((= rn_colr "D") (SETQ rn_colr "13")) ((= rn_colr "E") (SETQ rn_colr "14")) ((= rn_colr "F") (SETQ rn_colr "15")) ) ;_ end of COND (WRITE-LINE rn_colr rnlay_dat) (CLOSE rnlay_dat) (SETQ rllst (APPEND (LIST (CONS clayr rlnm)) rllst)) ) ;_ end of PROGN ) ;_ end of if (IF (AND clayr rlnm (NOT (EQ rlnm "*"))) (PROGN (SETQ rlex (MEMBER rlnm lay_list)) (IF (OR rlex (TBLSEARCH "layer" rlnm)) (PROGN (PRINC (STRCAT "\n" rlnm " exists, entities' layer changed to " rlnm ) ;_ end of strcat ) ;_ end of princ (SETQ z (CONS 8 clayr)) (SETQ chglss (SSGET "x" (LIST z))) (IF chglss (PROGN (PRINC (STRCAT "\nEntities on layer " clayr " found") ) ;_ end of princ (SETQ clssln (SSLENGTH chglss)) (SETQ cntr 0) (WHILE (IF (< cntr clssln) (SETQ lent (ENTGET (SSNAME chglss cntr))) ) ;_ end of if (SETQ edlanm (ENTGET (CDAR lent))) (PROGN (SETQ edlanm (SUBST (CONS 8 rlnm) (ASSOC 8 edlanm) edlanm ) ;_ end of subst ) ;_ end of setq (ENTMOD edlanm) ) ;_ end of progn (SETQ cntr (1+ cntr)) ) ;_ end of while (PRINC (STRCAT "\nEntities changed to layer " rlnm) ) ;_ end of PRINC ) ;_ end of progn ) ;_ end of if ) ;_ end of progn (PROGN (COMMAND ".rename" "la" clayr rlnm) (PRINC (STRCAT "\nLayer " clayr " renamed to " rlnm)) ) ;_ end of progn ) ;_ end of if ) ;_ end of progn (PRINC (STRCAT "\nLayer " clayr " kept. ")) ) ;_ end of if ) ;_ end of progn ) ;_ end of if ) ;_ end of IF ; ) ;_ end of if ) ;_ end of foreach (SETVAR "regenmode" rg_mode) (SETVAR "cmdecho" cmd_echo) (PRINC) ) ;_ end of defun (DEFUN getdefs () (SETQ nlndef (STRCAT ;begin major group (IF (AND (OR (= (SUBSTR clayr 2 1) "-") (clltxst)) (clcoxst) (clmgxst) ) ;_ end of and (SUBSTR clayr 1 1) (IF mjrg mjrg "C" ) ;_ end of IF ) ;_ end of if ;; (princ (if mjrg mjrg "C")) ;;begin linetype (COND ((= (SUBSTR clayr 1 4) "PEGC") (SETQ rn_ltyp "hidden" lltyp "H" ) ;_ end of SETQ ) ((= (SUBSTR clayr 8 4) "EXST") (SETQ lltyp (SUBSTR clayr 2 1)) (COND ((= (STRCASE lltyp) "C") (SETQ rn_ltyp "center")) ((= (STRCASE lltyp) "N") (SETQ rn_ltyp "center2")) ((= (STRCASE lltyp) "D") (SETQ rn_ltyp "dashed")) ((= (STRCASE lltyp) "T") (SETQ rn_ltyp "dashdot")) ((= (STRCASE lltyp) "V") (SETQ rn_ltyp "divide")) ((= (STRCASE lltyp) "H") (SETQ rn_ltyp "hidden")) ((= (STRCASE lltyp) "M") (SETQ rn_ltyp "match")) ((= (STRCASE lltyp) "P") (SETQ rn_ltyp "phantom")) ((= (STRCASE lltyp) "Q") (SETQ rn_ltyp "phantom2")) ((= (STRCASE lltyp) "S") (SETQ rn_ltyp "streamd")) ((= (STRCASE lltyp) "-") (SETQ rn_ltyp "continuous")) ) ;_ end of COND lltyp ) ((= lltyp "CENTER") (SETQ rn_ltyp lltyp lltyp "C" ) ;_ end of SETQ ) ((= lltyp "CENTER2") (SETQ rn_ltyp lltyp lltyp "N" ) ;_ end of SETQ ) ((= lltyp "DASHED") (SETQ rn_ltyp lltyp lltyp "D" ) ;_ end of SETQ ) ((= lltyp "DASHDOT") (SETQ rn_ltyp lltyp lltyp "T" ) ;_ end of SETQ ) ((= lltyp "DIVIDE") (SETQ rn_ltyp lltyp lltyp "V" ) ;_ end of SETQ ) ((= lltyp "HIDDEN") (SETQ rn_ltyp lltyp lltyp "H" ) ;_ end of SETQ ) ((= lltyp "MATCH") (SETQ rn_ltyp lltyp lltyp "M" ) ;_ end of SETQ ) ((= lltyp "PHANTOM") (SETQ rn_ltyp lltyp lltyp "P" ) ;_ end of SETQ ) ((= lltyp "PHANTOM2") (SETQ rn_ltyp lltyp lltyp "Q" ) ;_ end of SETQ ) ((= lltyp "STREAMD") (SETQ rn_ltyp lltyp lltyp "S" ) ;_ end of SETQ ) ((= lltyp "CONTINUOUS") (SETQ rn_ltyp lltyp lltyp "-" ) ;_ end of SETQ ) ((SETQ rn_ltyp "continuous" lltyp "-" ) ;_ end of SETQ ) ) ;_ end of cond ;; (princ lltyp) ;;begin minor group (SETQ minor (COND ((AND (clmgxst) (> (STRLEN clayr) 5) (= (SUBSTR clayr 2 1) "-") ) ;_ end of and (SUBSTR clayr 3 4) ) ((AND (clmgxst) (> (STRLEN clayr) 5) (= (SUBSTR clayr 2 1) "X") ) ;_ end of and (SUBSTR clayr 3 4) ) ((AND (clmgxst) (> (STRLEN clayr) 5) (= (SUBSTR clayr 2 1) "H") (NOT (= (SUBSTR clayr 1 5) "SHEET")) ) ;_ end of and (SUBSTR clayr 3 4) ) ((AND (clmgxst) (> (STRLEN clayr) 5) (= (SUBSTR clayr 2 1) "C") ) ;_ end of and (SUBSTR clayr 3 4) ) ((AND (clmgxst) (> (STRLEN clayr) 5) (= (SUBSTR clayr 2 1) "D") ) ;_ end of and (SUBSTR clayr 3 4) ) ((AND (clmgxst) (> (STRLEN clayr) 5) (= (SUBSTR clayr 2 1) "F") ) ;_ end of and (SUBSTR clayr 3 4) ) ((AND (clmgxst) (> (STRLEN clayr) 5) (= (SUBSTR clayr 2 1) "M") ) ;_ end of and (SUBSTR clayr 3 4) ) ((AND (clmgxst) (> (STRLEN clayr) 5) (= (SUBSTR clayr 2 1) "N") ) ;_ end of and (SUBSTR clayr 3 4) ) ((AND (clmgxst) (> (STRLEN clayr) 5) (= (SUBSTR clayr 2 1) "P") ) ;_ end of and (SUBSTR clayr 3 4) ) ((AND (clmgxst) (> (STRLEN clayr) 5) (= (SUBSTR clayr 2 1) "Q") ) ;_ end of and (SUBSTR clayr 3 4) ) ((AND (clmgxst) (> (STRLEN clayr) 5) (= (SUBSTR clayr 2 1) "S") ) ;_ end of and (SUBSTR clayr 3 4) ) ((AND (clmgxst) (> (STRLEN clayr) 5) (= (SUBSTR clayr 2 1) "T") ) ;_ end of and (SUBSTR clayr 3 4) ) ((AND (clmgxst) (> (STRLEN clayr) 5) (= (SUBSTR clayr 2 1) "V") ) ;_ end of and (SUBSTR clayr 3 4) ) ((OR (= clayr "DIML") (= clayr "DIM") (= clayr "DIMS") ) ;_ end of OR "DIMS" ) ((= (SUBSTR clayr 1) "SHEET") "SHBD") ((OR (= (SUBSTR clayr 1 5) "TITLE") (= (SUBSTR clayr 7 5) "TITLE") (= (SUBSTR clayr 1 6) "CLIENT") ) ;_ end of or "TTLB" ) ((OR (= (SUBSTR clayr 1 8) "CONT-HGH") (= (SUBSTR clayr 1 8) "CONT-NML") ) ;_ end of or "CONT" ) ((= (SUBSTR clayr 1 8) "DCA_INFO") "DCA_") ((= (SUBSTR clayr 1 8) "TIN-VIEW") "TINV") ((> (STRLEN clayr) 3) (SUBSTR clayr 1 4)) ((< (STRLEN clayr) 4) "DETL") ((IF minor minor "DETL" ) ;_ end of IF ) ) ;_ end of cond ) ;_ end of setq ;; (princ minor) ;;begin color ;;(if tcolr ;; (if tclist ;; (if (assoc lcolr tclist) ;; (setq lcolr (cdr(assoc lcolr tclist))) ;; );if ;; (transc) ;; );if (SETQ lcolr (COND ((= (SUBSTR clayr 1 8) "CONT-HGH") (SETQ rn_colr 14 co_str "E" ) ;_ end of SETQ ) ((= (SUBSTR clayr 1 8) "CONT-NML") (SETQ rn_colr 15 co_str "F" ) ;_ end of SETQ ) ((= (SUBSTR clayr 1 4) "PEGC") (SETQ rn_colr 3 co_str "3" ) ;_ end of SETQ ) ((= lcolr 1) (SETQ rn_colr lcolr co_str "1" ) ;_ end of SETQ ) ((= lcolr 2) (SETQ rn_colr lcolr co_str "2" ) ;_ end of SETQ ) ((= lcolr 3) (SETQ rn_colr lcolr co_str "3" ) ;_ end of SETQ ) ((= lcolr 4) (SETQ rn_colr lcolr co_str "4" ) ;_ end of SETQ ) ((= lcolr 5) (SETQ rn_colr lcolr co_str "5" ) ;_ end of SETQ ) ((= lcolr 6) (SETQ rn_colr lcolr co_str "6" ) ;_ end of SETQ ) ((= lcolr 7) (SETQ rn_colr lcolr co_str "7" ) ;_ end of SETQ ) ((= lcolr 8) (SETQ rn_colr lcolr co_str "8" ) ;_ end of SETQ ) ((= lcolr 9) (SETQ rn_colr lcolr co_str "9" ) ;_ end of SETQ ) ((= lcolr 10) (SETQ rn_colr lcolr co_str "A" ) ;_ end of SETQ ) ((= lcolr 11) (SETQ rn_colr lcolr co_str "B" ) ;_ end of SETQ ) ((= lcolr 12) (SETQ rn_colr lcolr co_str "C" ) ;_ end of SETQ ) ((= lcolr 13) (SETQ rn_colr lcolr co_str "D" ) ;_ end of SETQ ) ((= lcolr 14) (SETQ rn_colr lcolr co_str "E" ) ;_ end of SETQ ) ((= lcolr 15) (SETQ rn_colr lcolr co_str "F" ) ;_ end of SETQ ) ((AND (> (STRLEN clayr) 7) (= (SUBSTR clayr 7 1) "-") (= (TYPE (READ (SUBSTR clayr 8 1))) 'int) (= lcolr "1") ) ;_ end of and (SETQ rn_colr (ATOI (SUBSTR clayr 8 1)) co_str (SUBSTR clayr 8 1) ) ;_ end of SETQ ) ((= clayr "TEXT") (SETQ rn_colr 6 co_str "6" ) ;_ end of SETQ ) ((SETQ rn_colr 1 co_str "1" ) ;_ end of SETQ ) ) ;_ end of cond ) ;_ end of setq ;;);if ;; (princ lcolr) ;;begin modifier (SETQ modf (COND ((= (SUBSTR clayr 1) "SHEET") "SYMB") ((= (SUBSTR clayr 1 8) "CONT-HGH") "NX05") ((= (SUBSTR clayr 1 8) "CONT-NML") "NM01") ((= (SUBSTR clayr 8 4) "EXST") "XIST") ((= (SUBSTR clayr 1) "EDTINAP") "NAP") ((= (SUBSTR clayr 1) "EDTINDL") "NDL") ((= (SUBSTR clayr 1) "EDTINAL") "NAL") ((IF (AND (> (STRLEN clayr) 11) (= (SUBSTR clayr (- (STRLEN clayr) 3)) "BLOC") ) ;_ end of and "SYMB" ) ;_ end of if ) ((IF (AND (> (STRLEN clayr) 11) (= (SUBSTR clayr 12 1) "P") (OR (= (SUBSTR clayr 9 1) "S") (= (SUBSTR clayr 9 1) "D") ) ;_ end of or ) ;_ end of and (SUBSTR clayr 8) ) ;_ end of if ) ((OR (= (SUBSTR clayr 1 8) "DCA_INFO") (= (SUBSTR clayr 1 5) "TITLE") (= (SUBSTR clayr 7 5) "TITLE") (= (SUBSTR clayr 1 6) "CLIENT") ) ;or "INFO" ) ((IF (AND (< (STRLEN clayr) 4) (/= lcolr clayr)) clayr "" ) ;_ end of if ) ) ;_ end of cond ) ;_ end of setq ;;(princ modf) ) ;_ end of strcat ) ;_ end of setq (PRINC) ) ;defun (DEFUN fix_lay (/) (laylst) (SETQ rnlay_lst nil) (SETQ rnlay_dat (OPEN "U:/LSP/RNLAY.DAT" "r")) (IF rnlay_dat (PROGN (WHILE (SETQ rd_line (READ-LINE rnlay_dat)) (IF rnlay_lst (SETQ rnlay_lst (APPEND rnlay_lst (LIST rd_line))) (SETQ rnlay_lst (LIST rd_line)) ) ;_ end of IF ) ;_ end of WHILE (CLOSE rnlay_dat) (SETQ rnlst_ln (/ (LENGTH rnlay_lst) 4)) (SETQ count 0) (WHILE (< count rnlst_ln) (IF (MEMBER (STRCASE (NTH (1+ (* count 4)) rnlay_lst)) lay_list) (PROGN (COMMAND "_.layer" "lt" (NTH (+ (* count 4) 2) rnlay_lst) (NTH (1+ (* count 4)) rnlay_lst) "c" (NTH (+ (* count 4) 3) rnlay_lst) (NTH (1+ (* count 4)) rnlay_lst) "" ) ; (SETQ lay_list (APPEND lay_list (LIST (STRCASE (NTH (1+(* count 4)) rnlay_lst))))) ) ;_ end of PROGN ) ;_ end of IF (SETQ count (1+ count)) ) ;_ end of WHILE ) ;_ end of PROGN ) ;_ end of IF ) ;_ end of DEFUN (DEFUN rnlay (/) (SETQ rnlay_lst nil) (SETQ rnlay_dat (OPEN "U:/LSP/RNLAY.DAT" "r")) (IF rnlay_dat (PROGN (WHILE (SETQ rd_line (READ-LINE rnlay_dat)) (IF rnlay_lst (SETQ rnlay_lst (APPEND rnlay_lst (LIST rd_line))) (SETQ rnlay_lst (LIST rd_line)) ) ;_ end of IF ) ;_ end of WHILE (CLOSE rnlay_dat) (SETQ rnlst_ln (/ (LENGTH rnlay_lst) 4)) (SETQ count 0) (WHILE (< count rnlst_ln) (IF (SETQ rn_elay (CAR (MEMBER (NTH (* count 4) rnlay_lst) lay_list)) ) ;_ end of SETQ (PROGN (IF (SETQ rn_layer (CAR (MEMBER (STRCASE (NTH (1+ (* count 4)) rnlay_lst)) lay_list ) ;_ end of MEMBER ) ;_ end of CAR ) ;_ end of SETQ (PROGN (PRINC (STRCAT "\nChanging entities on " rn_elay " to " rn_layer "." ) ;_ end of STRCAT ;_ end of STRCAT ) ;_ end of PRINC (SETQ lay_list (SUBST rn_layer rn_elay lay_list)) (SETQ flst 'alst) (SETQ alst (LIST (CONS 8 rn_elay))) (SETQ ss1 (SSGET "x" (EVAL flst))) (IF ss1 (COMMAND ".chprop" ss1 "" "la" rn_layer "") (PRINC (STRCAT "\nNo entities on layer " rn_elay "!")) ) ;_ end of IF ) ;_ end of PROGN (IF (TBLSEARCH "layer" rn_elay) (PROGN (COMMAND "_.rename" "la" rn_elay (STRCASE (NTH (1+ (* count 4)) rnlay_lst)) ) ;_ end of COMMAND (SETQ lay_list (APPEND lay_list (LIST (STRCASE (NTH (1+ (* count 4)) rnlay_lst)) ) ;_ end of LIST ) ;_ end of APPEND ) ;_ end of SETQ (PRINC (STRCAT "\nLayer " (STRCASE (NTH (1+ (* count 4)) rnlay_lst)) "appended to lay_list" ) ;_ end of STRCAT ) ;_ end of PRINC ) ;_ end of PROGN ) ;_ end of IF ) ;_ end of IF (COMMAND "_.layer" "lt" (NTH (+ (* count 4) 2) rnlay_lst) rn_layer "c" (NTH (+ (* count 4) 3) rnlay_lst) rn_layer "" ) ;_ end of COMMAND ) ;_ end of PROGN ) ;_ end of IF (SETQ count (1+ count)) ) ;_ end of WHILE ) ;_ end of PROGN ) ;_ end of IF ) ;_ end of DEFUN (DEFUN laylst (/ it itn lay_f lay_str) (PROGN (SETQ it (TBLNEXT "layer" "T")) (SETQ itn (CDR (ASSOC 2 it))) (SETQ lay_list (LIST itn)) (WHILE (SETQ it (TBLNEXT "layer")) (PROGN (SETQ itn (CDR (ASSOC 2 it))) (SETQ lay_list (APPEND lay_list (LIST itn))) ) ;progn ) ;while (SETQ lay_list (ACAD_STRLSORT lay_list)) ) ;progn ) ;defun (PRINC) ;(defun transc (/) ; (setq cvtyp (ukword 1 "Archi Elect Struc Other" "Source to translate (Arch, Elec, Stru, Other) " "") ; tcinpf (strcat(getvar"dwgprefix")cvtyp ".tct")) ; (if(findfile tcinpf) ; (progn ; (setq tcinp (open tcinpf "r")) ; (setq xcstr "" tcstr "") ; (while ; (and ; (setq rchar (read-char tcinp)) ; (not(eq rchar (chr 10))) ; );and ; (while ; (not(eq rchar (chr 32))) ; (setq xcstr (strcat xcstr (itoa rchar))) ; );while ; (while ; rstr ; (setq tcstr (strcat tcstr (itoa rchar))) ; );while ; (if tclist ; (setq tclist(append tclist (cons xcstr tcstr))) ; (setq tclist (cons xcstr tcstr)) ; );if ; );while ; (close tcinp) ; (if (assoc lcolr tclist) ; (setq lcolr (cdr(assoc lcolr tclist))) ; );if ; );progn ; (progn ; (setq tclist nil) ; (princ (strcat"\n" tcinpf " not found. Colors will not be translated. ")) ; );progn ; );if ;);defun ;|«ViLL© FORMAT OPTIONS...» (72 2 40 2 T "end of " 60 9 2 0 0 T T nil T) ***Don't add text below the comment!***|; ;|«Visual LISP© Format Options» (72 2 40 2 T "end of " 60 9 2 0 0 T T nil T) ;*** DO NOT add text below the comment! ***|;