; ** 12-Mar-07 NEHolt created as example ; --------- M A R K T E R M _ E X T E R N A L . L S P --------- (defun c:markterm_external ( / ss slen ix ben pntlst wirelst wconn hit wire_en field_layername_wildcard ed newval oldval nochange tagstrip termno wlayer xterm_attr_nam) ; Process all windowed terminals on active drawing. For any ; wire connection tied to a "field" or "customer" wire layer, ; mark that terminal's wire connection as "E" external. This ; will help set up Terminal Strip Editor utility to more ; quickly generate a terminal strip representation with field ; wiring all on one side. (setq field_layername_wildcard "*FIELD*,*CUSTOMER*") (princ "\nSelect schematic terminals to process:") (setq ss (ssget '((-4 . "")))) ; Note: the above will not find flipped "dynamic blocks" ; Process the selected terminals... (if (/= ss nil) (progn (setq slen (sslength ss)) ; number of ents in selection set (setq ix 0) ; use as index counter into selection set (while (< ix slen) (setq ben (ssname ss ix)) ; get next term from selection set ; Get terminal "TAGSTRIP" and "TERM/WIRENO" value (setq tagstrip (c:wd_getattrval ben "TAGSTRIP*")) (setq termno (c:wd_getattrval ben "TERM01,WIRENO")) ; Get list of wire connections that tie to this ; terminal (setq pntlst (c:wd_get_sym_pntlst ben nil nil)) ; For each wire connection point on this terminal symbol... (foreach wconn pntlst ; wcon = (list indx xy nil wirelst xdir suffix xterm_en ; multi_wire_lst future jumpers_attr_en) ; Get list of any wires that tie to this wire connection ; point on this terminal (setq wirelst (nth 3 wconn)) (setq hit nil) ; For each wire tied to this wire connection point ; (if any...) (foreach wire_en wirelst (setq ed (entget wire_en)) ; open wire entity (setq wlayer (cdr (assoc 8 ed))) ; wire's layer ; Compare wlayer name against wildcard listing (if (wcmatch (strcase wlayer) field_layername_wildcard) (progn ; yes, this wire is a "field" wire. (setq hit T) ) ) ) (if hit (progn ; yes, this wire connection point is a "field" ; wire connection. Need to mark it with "E" for ; "External" connection. ; Figure out what the X?TERMxx attribute name is ; going to be. (setq xterm_attr_nam (strcat "X" (itoa (nth 4 wconn)) "TERMDESC" (nth 5 wconn))) ; Get current value of this attribute (setq oldval (c:wd_getattrval ben xterm_attr_nam)) (setq newval nil) (setq nochange nil) (cond ((= oldval nil)) ; some problem, attrib not present ((= oldval "")(setq newval "E")) ; simple update ((= oldval "E")(setq nochange oldval)) ; no chg req'd ((/= (setq pos (c:ace_find_substr oldval "E:" 1)) nil) (setq nochange oldval)) ; no chg req'd ((/= (setq pos (c:ace_find_substr oldval "I:" 1)) nil) ; Flip the I: to E: (setq newval (strcat (substr oldval 1 (1- pos)) "E:" (substr oldval (+ pos 2)))) ) ) (if (OR newval nochange) (progn (princ "\n") ; output the terminal TAGSTRIP value (princ tagstrip) (if (/= termno "") (progn (princ ":") (princ termno) ) ) ; output the handle number of this terminal (princ " hdl=") (princ (cdr (assoc 5 (entget ben)))) (princ ", lay=") ; output the connected wire's layer name (princ wlayer) (princ ", ") ; output the X?TERMxx attribute name (princ xterm_attr_nam) (princ " ") (cond ((/= newval nil) ; Write new value back to terminal's invisible ; X?TERMxx attribute (c:wd_modattrval ben xterm_attr_nam newval nil) (if (= oldval "")(setq oldval "(blank)")) (princ oldval) (princ "-->") (princ newval) ) (T ; no change required (princ "(no change)") ) ) ) ) ) ) ) (setq ix (1+ ix)) ; increment index ) ) (setq ss nil) ; release the selection set ) (princ) ; silent return )