; 21-Apr-08 NEHolt created (defun c:wn_textcolor ( / ss slen ix wnum_txt wire_layername ed x wire_ent wnum_ent newed str hdl wndata wire_lay lst look_for_wire_leader) ; PURPOSE: force WIRENO or WIRENOF attr color to match ; the display color of the attached wire LINE entity. ; -- internal function -- (defun look_for_wire_leader ( wnum_ent wire_lay / hdl ) (if (setq hdl (c:wd_get_1005_xdata wnum_ent "VIA_WD_WNLEADER")) (progn ; move the leader to the new wire layer too (command "_.CHPROP" (handent hdl) "" "_LAYER" wire_lay "") ) ) ) ; -- main program starts here ; Find all block inserts that appear to be wire numbers (setq ss (ssget "_X" '((-4 . "")))) (if (/= ss nil) (progn ; some found, continue processing (setq slen (sslength ss)) ; count of wire number inserts (setq ix 0) ; index (while (< ix slen) ; get next wire number to process (setq wnum_ent (ssname ss ix)) ; Get attribute entity name of the ; value "WIRENO" or "WIRENOF" off of this insert ; Returns list of attrval, attrname, attr_ent_name (setq wndata (c:ace_getattr_data wnum_ent "WIRENO*")) (setq wnum_txt (car wndata)) (if (AND wnum_txt (/= wnum_txt "")) (progn ; non-blank wirenumber found ; Find LINE wires tied to this wire number (setq x (c:ace_wnum_find_wire_en wnum_ent nil)) (if (AND x (car x)) (progn ; Found wire. Check its layer name. ; wirenum block insert is 1st element of ; return (setq wire_ent (car x)) (setq ed (entget wire_ent)) ; Layer name of wire LINE entity is subrec 8 (setq wire_lay (cdr (assoc 8 ed))) ; Flip the WIRENO attribute to be on the ; same layer as the LINE wire. This should ; make the wire number text display as the ; same screen color as the wire. ; Open WIRENO attr (setq ed (entget (caddr wndata))) ; Substitute wire layer name into attribute's ; record (setq newed (subst (cons 8 wire_lay) (assoc 8 ed) ed)) ; Write new data out to the attribute entity (entmod newed) ; Update any "wire number leader" if ; exists. Move to same layer as the ; wire number attribute. (look_for_wire_leader wnum_ent wire_lay) ; Now, look for any "Wire number copies" ; These will appear as a comma-delimited handle ; list carried on Xdata "VIA_WD_WNCOPY" on ; the main wire number block insert. (setq str (c:wd_get_1000_xdata wnum_ent "VIA_WD_WNCOPY")) ; Xdata found. Process if non-blank value. (if (AND str (/= str "")) (progn ; Break down into a list of handle pointers (setq lst (c:wd_delim_str_to_lst str ",")) (if lst (progn ; this is a list of "handles" (foreach x lst ; process each handle ; Convert handle to entity name. This ; will be the "extra wire number" ; block insert instance. (setq wnum_ent (handent x)) ; Get "WIRECOPY" attribute data (setq wndata (c:ace_getattr_data wnum_ent "WIRECOPY")) ; Get WIRECOPY attribute text value (setq wnum_txt (car wndata)) (if (AND wnum_txt (/= wnum_txt "")) (progn ; non-blank, go ahead and ; process (setq ed (entget (caddr wndata))) ; Flip to same layer as main wire ; number's underlying LINE wire ; layer. (setq newed (subst (cons 8 wire_lay) (assoc 8 ed) ed)) (entmod newed) ;update the attribute ; Update any "wire number leader" if ; exists. Move to same layer as the ; wire number attribute. (look_for_wire_leader wnum_ent wire_lay) ) ) ) ) ) ) ) ) ) ) ) (setq ix (1+ ix)) ; increment index to process ; next wire number ) (setq ss nil) ; release the selection set ) ) (princ) ; suppress any return )