; 06-Mar-07 PMMurnen created (stolen and modified from textvals_upd.lsp created by NEHolt) ; entry point that can be used in a script and will do all compionents (defun c:weblink_upd_all ( / ss) (setq ss (ssget "_X" '((0 . "INSERT")))) (if ss (weblink_upd_main ss)) (setq ss nil) (princ) ) ; -- entry point to allow entity selection (defun c:weblink_upd ( / ) (princ "\nSelect AcadE objects for WEBLINK and PINLIST update") (setq ss (ssget '((0 . "INSERT")))) (if (/= ss nil) (weblink_upd_main ss)) (setq ss nil) (princ) ) ; -- (defun weblink_upd_main (ss / asmb cat ch en hit ix max4 maxnc maxno maxnonc mfg pinval slen weblink x xx xxx) (setq slen (sslength ss)) (setq ix 0) (while (< ix slen) (setq en (ssname ss ix)) ; Check if component carries non-blank CAT/MFG attribute values. ; If so, do a query on catalog lookup and retrieve any WEBLINK and PINLIST ; that might be found for the matching catalog lookup record. (setq cat (c:wd_getattrval en "CAT")) (if (AND cat (/= cat "")) (progn (setq mfg (c:wd_getattrval en "MFG")) (if (AND mfg (/= mfg "")) (progn (if (not (setq asmb (c:wd_getattrval en "ASSYCODE"))) (setq asmb "") ; no ASSYCODE attrib, set to blank ) ; Look for PINLIST info. Rtrn= (list "coilpin1,coilpin2" ; "type1,pin1a,pin1b;type2,pin2a,pin2b;...") (if (setq x (c:wd_get_pinlist mfg cat asmb)) (progn (if (AND (car x) (/= (car x) "")) ; coil pins, comma delimited (progn (if (setq xxx (c:wd_delim_str_to_lst (car x) ",")) (progn ; now write coil pins out to TERM01, TERM02... (setq xx 1) (foreach pinval xxx (cond ((< xx 10) (c:wd_modattrval en (strcat "TERM0" (itoa xx)) pinval nil) ) (T (c:wd_modattrval en (strcat "TERM" (itoa xx)) pinval nil)) ) (setq xx (1+ xx)) ) ) ) ) ) ; Put child pin info on component's PINLIST attrib or as xdata (if (AND (cadr x)(/= (cadr x) "")) (progn (if (c:wd_upd_pnlval en "PINLIST" (cadr x)) (progn (princ "\nPINLIST --> ") (princ (cadr x)) ) ) ; Also set the MAXNO and MAXNC and MAXNONC xdata values (setq xxx (c:wd_delim_str_to_lst (cadr x) ";")) (setq maxno 0) (setq maxnc 0) (setq maxnonc 0) (setq max4 0) (setq hit nil) (foreach x xxx (setq ch (substr x 1 1)) ; get first character (cond ((= ch "0") (setq maxnonc (1+ maxnonc)) (setq hit T) ) ((= ch "1") (setq maxno (1+ maxno)) (setq hit T) ) ((= ch "2") (setq maxnc (1+ maxnc)) (setq hit T) ) ((= ch "3") ; Form-C (setq maxno (1+ maxno)) (setq maxnc (1+ maxnc)) (setq hit T) ) ((= ch "4") (setq max4 (1+ max4)) (setq hit T) ) ) ) (if hit (progn ; update the maximum counts (c:wd_upd_pnlval en "MAXNO" (itoa maxno)) (c:wd_upd_pnlval en "MAXNC" (itoa maxnc)) (c:wd_upd_pnlval en "MAXNONC" (itoa maxnonc)) (c:wd_upd_pnlval en "MAXTYPE4" (itoa max4)) ) ) ) ) ) ) ; do WEBLINK info (setq GBL_wd_cat3_getcat_weblink nil) (if (setq x (wd_cat3_getcat2 nil mfg cat asmb (cdr (assoc 2 (entget en))))) (progn (setq weblink nil) ; prior to AcadE 2008 the weblink was placed in GBL_wd_cat3_getcat_weblink ; after that as part of return (if GBL_wd_cat3_getcat_weblink (setq weblink GBL_wd_cat3_getcat_weblink) ; else (progn (if (AND (> (length x) 2) (setq x (nth 2 x)) (listp x) ) (progn (setq weblink (cadr (car x))) ) ) ) ) ; has a weblink value (if (AND weblink (= (type weblink) 'STR) (c:wd_upd_pnlval en "WD_WEBLINK" weblink)) (progn (princ "\nWEBLINK --> ") (princ weblink) ) ) (setq GBL_wd_cat3_getcat_weblink nil) ) ) ) ) ) ) (setq ix (1+ ix)) ) (setq ss nil) )