; ** 12-Apr-09 NEHolt reworked to look for drawing-wide INST/LOC assignments ; ** 16-Feb-08 NEHolt fixed typo in original ; ------- W N U M _ R M V _ I E C _ S U F F I X . L S P ------ (defun c:rmv ( / ss delim_char slen ix wnum_en pos wen newnum attrname) ; PURPOSE: remove IEC wire number suffix when INST/LOC values match up ; with drawing-wide INST/LOC assignments... leaving just bare wire number. ; This works on both normal wire numbers and in-line wire numbers. It updates ; any extra wire number "copies" as well. ; Note: this will process and modify just "normal" (i.e. non-fixed) wire numbers ; unless adjustment made immediately below. ; ************ ; To process both normal and "fixed" wire numbers, uncomment line "WIRENO*" and ; comment out the "WIRENO" line. ; To process just "normal" wire numbers and leave "Fixed" untouched, uncomment ; the "WIRENO" line below and comment out the "WIRENO*" line. ; (uncomment just one of the two lines below - remove the line's leading ";" character) ; (setq attrname "WIRENO*") ; uncomment this line to process both normal and fixed (setq attrname "WIRENO") ; uncomment this line to process just "normal" (fixed untouched) ; ************ ; Search for schematic wire number instances. This includes in-line wire number ; instances. (setq ss (ssget "_X" '((-4 . "")))) (if (/= ss nil) (progn ; active drawing carries some wire number instances. Continue. ; Get drawing-wide INST and LOC assignments (wd_cfg_read_dwg_params) ; read the WD_M block and set GBL_wd_m global (setq inst (nth 52 GBL_wd_m)) ; get INST from drawing properties (setq loc (nth 53 GBL_wd_m)) ; get LOC value from drawing properties (setq slen (sslength ss)) (setq ix 0) (while (< ix slen) (setq wnum_en (ssname ss ix)) ; get wire number entity (setq ix (1+ ix)) ; increment for next time ; Get wire number text (either WIRENO* or WIRENO attribute name) (if (setq wnum_val (c:wd_getattrval wnum_en attrname)) (progn (setq save_val wnum_val) ; save copy for comparison later (if (AND inst (/= inst "")) (progn ; Look for INST prefix on this wire number string (if (= (substr wnum_val 1 (strlen inst)) inst) (progn ; Exact match with INST value. Strip it off (setq wnum_val (substr wnum_val (1+ (strlen inst)))) ) ; ELSE (progn (if (= (substr wnum_val 1 (1+ (strlen inst))) (strcat "=" inst)) (progn ; Exact match with "=INST" value. Strip it off. (setq wnum_val (substr wnum_val (+ 2 (strlen inst)))) ) ) ) ) ) ) (if (AND loc (/= loc "")) (progn ; Look for LOC prefix on this wire number string (if (= (substr wnum_val 1 (strlen loc)) loc) (progn ; Exact match with INST value. Strip it off (setq wnum_val (substr wnum_val (1+ (strlen loc)))) ) ; ELSE (progn (if (= (substr wnum_val 1 (1+ (strlen loc))) (strcat "+" loc)) (progn ; Exact match with "=INST" value. Strip it off. (setq wnum_val (substr wnum_val (+ 2 (strlen loc)))) ) ) ) ) ) ) (if (/= wnum_val save_val) (progn ; Something was stripped off. Push bare wire number back ; out to the wire network. ; Remove any leading "-" prefix on the wire number (if (= (substr wnum_val 1 1) "-")(setq wnum_val (substr wnum_val 2))) ; Now get the entity name of the wire that passes under this ; wire number instance. (if (setq wen (car (c:ace_wnum_find_wire_en wnum_en GBL_wd_trp))) (progn ; Found it. Push revised wire number back out. Update ; any extra wire number "copies" found on the wire network. (princ "\n") (princ save_val) (princ " --> ") (princ wnum_val) (c:wd_putwn wen wnum_val) ) ) ) ) ) ) ) (setq ss nil) ) ) (princ) )