; ** 09-Oct-2008 NEHolt created ; -------- W I R E T Y P E _ A N N O . L S P ------- (defun c:wiretype_anno ( / rtrn dwgix laynam ben blknam color size x ed wtlst lst wen xitflg) ; PURPOSE: push WIRETYPE's "color" and "size" settings ; out to target attributes on picked Source or ; Destination arrow symbol. ; -- internal functions -- (defun get_wiretype_data ( laynam / rtrn dwgix) ; Find and return all data tied to target "laynam" ; on active drawing in active project. ; "laynam" = wiretype layer name (setq rtrn nil) (setq dwgix nil) ; Set global GBL_wd_cip which carries the position ; that active drawing is in relative to all drawings ; listed in the project's ".wdp" file. (if (OR (= GBL_wd_cip 0)(not GBL_wd_cip)) (wd_wdp_is_active_in_proj)) ; set the global ; Now figure out the drawing's DWGIX value that ; is used in the project's scratch database to ; identify this active drawing. (if (/= GBL_wd_cip 0) (setq dwgix (wd_mdb_wdp2ix_ix GBL_wd_cip))) ; Now call an API function that queries the ; active project's scratch database file tables ; WIRETYPE and WIRETYPE_USR to find all ; info about wiretype "laynam" as defined on ; the active drawing (i.e. the active drawing's ; "DWGIX" value. (if (AND laynam (/= laynam "") dwgix) (setq rtrn (ace_query_wiretype dwgix laynam)) ) rtrn ; nil=not found, otherwise a list of wire ; type COLOR, SIZE, and USER1-USER20 ) ; -- main program starts here -- (setq xitflg nil) (while (not xitflg) (setq xitflg T) ; default to exit loop ; Prompt user to pick on Source/Destination ; arrow that needs to be annotated. (setq x (entsel "\nSelect source/destination arrow:")) (if x (progn (setq ben (car x)) ; entity name of pick (setq ed (entget ben)) ; open it (if (= (cdr (assoc 0 ed)) "INSERT") (progn ; so far, so good (setq blknam (cdr (assoc 2 ed))) ; Make sure it is an arrow symbol (if (wcmatch blknam "?A#S*,?A#D*") (progn ; yes, keep going ; Look for attached wire (setq lst (c:wd_get_sym_pntlst ben 1 nil)) (if lst (progn ; go for first or only connection (setq wen (car (nth 3 (car lst)))) ; Get layer name of connected wire (setq laynam (cdr (assoc 8 (entget wen)))) ; Now get COLOR and SIZE info for this ; wire type (setq wtlst (get_wiretype_data laynam)) (if wtlst (progn ; have some data (setq color (car wtlst)) (setq size (cadr wtlst)) ; Push these on to the Source/Dest ; arrow symbol. ; ** SET TARGET ATTRIBUTE HERE ** (c:wd_modattrval ben "COLOR" color nil) (c:wd_modattrval ben "SIZE" size nil) (setq xitflg nil) ; stay in loop ) ) ) ) ) ) ) ) ) ) ) (princ) ; quiet return )