; 17-Dec-08 NEHolt created (defun c:audit_sig_layers ( / lst newlst x rtrn report_fnam source_wdata_lst ff q1 sig_table_data all_connections_lst dwgix_fnam_lst data dest_wdata_lst dst_laynam src_laynam dst_lst_layername dst_lst_wnum src_lst_wnum src_lst_layername src_lst_sigcode dst_lst_sigcode D_lst_wdata S_lst_wdata dst_lst_wdata dwgix fnam fout hit ix lay_lst netrec rec sigcode sigcodes_used sigrec wnum xx src_lst_wdata) ; -- internal -- (defun mdb_cdrlst ( data / lst newlst x rtrn) ; strip of dotted pairs from list of lists (setq rtrn nil) (if data (progn (foreach lst data (setq newlst '()) (foreach x lst (setq x (cdr x)) (if (= x " ") (setq x "")) (setq newlst (cons x newlst)) ) (setq rtrn (cons (reverse newlst) rtrn)) ) ) ) (reverse rtrn) ) ; -- main routine starts here -- (setq report_fnam "c:/sig_audit.rep") (setq source_wdata_lst nil) (setq fout nil) (setq dest_wdata_lst nil) (if (setq fnam (wd_mdb_proj_dbfnam nil)) ; get project scratch mdb file name for active project (progn (setq ff (wd_mdb_gethandle 1)) (if ff (progn (setq x (wd_mdb_Open ff fnam)) ; open active project's database file (if x (progn ; Query the SIG table to pull in source/dest arrow symbol info (setq q1 (wd_mdb_GetRecs ff "SIG" "DWGIX,SIGCODE,TYP,HDL" "" "")) (setq sig_table_data (mdb_cdrlst q1)) ; Query the WDATA table to pull in raw wire connection data (setq q1 (wd_mdb_GetRecs ff "WDATA" "CONNECTIONS" "" "")) (setq all_connections_lst (mdb_cdrlst q1)) ; Query the FILENAME table to get DWGIX/FILENAME combos (setq q1 (wd_mdb_GetRecs ff "FILETIME" "DWGIX,DWGNAME" "" "")) (setq dwgix_fnam_lst (mdb_cdrlst q1)) ) ) (wd_mdb_Close ff) (setq ff nil) ) ) ) ) (if (AND all_connections_lst sig_table_data) (progn (setq src_lst_sigcode nil) (setq src_lst_layername nil) (setq src_lst_wdata nil) (setq src_lst_wnum nil) (setq dst_lst_sigcode nil) (setq dst_lst_layername nil) (setq dst_lst_wdata nil) (setq dst_lst_wnum nil) (setq sigcodes_used nil) ; Process every wire connection. Look for component match-up with ; one of the source or destination arrows pulled from the "SIG" ; table. Save match-ups in parallel lists for future processing. (foreach x all_connections_lst (setq xx (read (car x))) ; Strip out list of connections for this part of the network (setq netrec (nth 3 xx)) ; Now evaluate each wire connection. Look for match with DWGIX ; and HDL in the list of source/destination arrow symbols ; pulled from the SIG table. (foreach rec netrec ; (nth 17 rec) = DWGIX ; (nth 18 rec) = HDL (setq hit nil) (foreach sigrec sig_table_data ; SIG data will be (list DWGIX SIGCODE TYP HDL) (if (not hit) (progn (if (AND (= (nth 18 rec) (substr (nth 3 sigrec) 3)) ; match on hdl (= (nth 17 rec) (car sigrec))) ; match on DWGIX (progn ; This component connection is a wire tied ; to a source or destination arrow. (setq hit T) ; remember have hit match for this one (cond ((= (caddr sigrec) "S") ; Source arrow (setq src_lst_sigcode (cons (strcase (cadr sigrec)) src_lst_sigcode)) (setq src_lst_layername (cons (nth 3 rec) src_lst_layername)) (setq src_lst_wnum (cons (car xx) src_lst_wnum)) (setq src_lst_wdata (cons rec src_lst_wdata)) ; Keep track of all unique SIGCODE values found (if (not (member (cadr sigrec) sigcodes_used)) (setq sigcodes_used (cons (cadr sigrec) sigcodes_used))) ) ((= (caddr sigrec) "D") ; Destination arrow (setq dst_lst_sigcode (cons (strcase (cadr sigrec)) dst_lst_sigcode)) (setq dst_lst_layername (cons (nth 3 rec) dst_lst_layername)) (setq dst_lst_wnum (cons (car xx) dst_lst_wnum)) (setq dst_lst_wdata (cons rec dst_lst_wdata)) ; Keep track of all unique SIGCODE values found (if (not (member (strcase (cadr sigrec)) sigcodes_used)) (setq sigcodes_used (cons (strcase (cadr sigrec)) sigcodes_used))) ) ) ) ) ) ) ) ) ) (if sigcodes_used (progn ; one or more SIGCODES used in the project, continue with eval. ; Open a text file for the report (setq fout (open report_fnam "w")) (if GBL_wd_prj (write-line GBL_wd_prj fout) ; output current project's name to report ) ; Evaluate the collected data. Look for sigcode values that point at ; different wire layer names. A list of unique SIGCODEs is held in ; "sigcodes_used". Process these one at a time. (foreach sigcode sigcodes_used (setq S_lst_wdata nil) (setq D_lst_wdata nil) (setq lay_lst nil) (setq ix 0) (foreach x src_lst_sigcode (if (= x sigcode) (progn ; found match, get wiretype layername (setq src_laynam (nth ix src_lst_layername)) (if (not (member src_laynam lay_lst)) (setq lay_lst (cons src_laynam lay_lst))) ; Save wnum and connection data in list in case it needs to be reported (setq S_lst_wdata (cons (list (nth ix src_lst_wnum)(nth ix src_lst_wdata)) S_lst_wdata)) ) ) (setq ix (1+ ix)) ) (setq ix 0) (foreach x dst_lst_sigcode (if (= x sigcode) (progn ; found DEST match, get wiretype layername (setq dst_laynam (nth ix dst_lst_layername)) (if (not (member dst_laynam lay_lst)) (setq lay_lst (cons dst_laynam lay_lst))) ; Save wnum and connection data in list in case it needs to be reported (setq D_lst_wdata (cons (list (nth ix dst_lst_wnum)(nth ix dst_lst_wdata)) D_lst_wdata)) ) ) (setq ix (1+ ix)) ) (if (> (length lay_lst) 1) (progn ; Problem with this SIGCODE. Linked Source/Dest going to ; mismatched wire types. (princ "\nSigcode: ")(princ sigcode) (princ " - mismatched wire type layers") ; Also output to report (princ "\nSigcode: " fout)(princ sigcode fout) (princ " - mismatched wire type layers" fout) (foreach x S_lst_wdata (setq wnum (car x)) (setq rec (cadr x)) (princ "\n (src) lay=\"")(princ "\n (src) lay=\"" fout) (princ (nth 3 rec))(princ (nth 3 rec) fout) (princ "\" wnum=\"")(princ "\" wnum=\"" fout) (princ wnum)(princ wnum fout) (princ "\" hdl=")(princ "\" hdl=" fout) (princ (nth 18 rec))(princ (nth 18 rec) fout) (princ " dwg=")(princ " dwg=" fout) (setq dwgix (nth 17 rec)) ; Get the actual drawing filename (setq fnam nil) (foreach x dwgix_fnam_lst ; x = (list DWGDIX DWGNAME) (if (= (car x) dwgix) (setq fnam (cadr x))) ) (if (not fnam)(setq fnam "")) (princ fnam)(princ fnam fout) ) (foreach x D_lst_wdata (setq wnum (car x)) (setq rec (cadr x)) (princ "\n (dst) lay=\"")(princ "\n (dst) lay=\"" fout) (princ (nth 3 rec))(princ (nth 3 rec) fout) (princ "\" wnum=\"")(princ "\" wnum=\"" fout) (princ wnum)(princ wnum fout) (princ "\" hdl=")(princ "\" hdl=" fout) (princ (nth 18 rec))(princ (nth 18 rec) fout) (princ " dwg=")(princ " dwg=" fout) (setq dwgix (nth 17 rec)) ; Get the actual drawing filename (setq fnam nil) (foreach x dwgix_fnam_lst ; x = (list DWGDIX DWGNAME) (if (= (car x) dwgix) (setq fnam (cadr x))) ) (if (not fnam)(setq fnam "")) (princ fnam)(princ fnam fout) ) (princ "\n---") ) ) ) ) ) ) ) (if fout (progn (princ "\nReport: ")(princ report_fnam) (close fout) (setq fout nil) ) ) (princ) )