; 07-Mar-07 NEHolt (defun c:add_cable_cat ( / scratch_fnam cablelst x hitrec rec cblname ben ix atnam slen ss loc inst tag ) ; Process tabular terminal strip representation. Insert ; CAT/MFG data for cable marker tags found in the table. (setq cablelst nil) ; Get active project's scratch database file name (if (setq scratch_fnam (c:wd_mdb_get_proj_scratch_dbnam nil)) (progn ; have active project's scratch database filename ; Query on the COMP table to get a list of all parent ; cable marker info (setq cablelst (wd_oledb_select scratch_fnam (strcat "SELECT DWGIX,TAGNAME,INST,LOC,MFG,CAT FROM [COMP]" " WHERE CATEGORY='C' AND PAR1_CHLD2='1' AND CAT <> ''"))) ) ) (if cablelst (progn ; some cable data found. Okay to continue. (princ "\nSelect tabular terminal strip rows to process") (setq ss (ssget '((0 . "INSERT")))) (if (/= ss nil) (progn (setq slen (sslength ss)) (setq ix 0) (while (< ix slen) (setq ben (ssname ss ix)) ; get next row to process ; Process attributes found in the table row's "Block". ; Sample here is two attributes for cable marker tag. ; One on left side of table row, one on right side. (foreach atnam (list "CABLENAMEL" "CABLENAMER") (setq cblname (c:wd_getattrval ben atnam)) (if (AND cblname (/= cblname "")) (progn ; go through list, look for a match on cable (setq hitrec nil) (foreach rec cablelst (setq tag (nth 1 rec)) (setq inst (nth 2 rec)) (setq loc (nth 3 rec)) ; Find match in database on the cable tag on dwg (if (OR (= cblname tag) ; Deal with IEC-style tags below (= cblname (strcat "-" tag)) (= cblname (strcat loc "-" tag)) (= cblname (strcat "+" loc "-" tag)) (= cblname (strcat "=" inst "+" loc "-" tag))) (progn ; found match (setq hitrec rec) ) ) ) (if hitrec (progn ; get CAT and MFG, append to cblname and ; write back out to the attribute in the ; tabular term strip row. (setq cblname (strcat cblname " (" (nth 4 hitrec) ; MFG " " (nth 5 hitrec) ; CAT ")")) ; Write new value back out to the cablename ; attribute (c:wd_modattrval ben atnam cblname nil) ) ) ) ) ) (setq ix (1+ ix)) ) (setq ss nil) ) ) ) ) (princ) )