(defun tb_concatenate ( linelst / fresh_wdm_in_memory x item linelst output_str fulldwglst desclst hit) ; Contatenate multiple project "LINEx" desc lines or ; other drawing-specific values into a single ; line of text to apply to a target title block ; attribute ; Format in ".wdt" file or set up on title block's ; invisible WD_TB attribute is this: ; =(tb_concatenate (list s1 s2 s3....)) ; where ; TB_ATTR_NAME= attribute tag name to receive the ; formated text ; s1,s2,s3...sn = substring flags to concatenate ; into one long string value where each value ; can be an integer number (to flag one of the ; project LINEx values), a flag for one of the ; drawing specific parameters, or a specific ; text string. ; Ex: to concatenate LINE3 and LINE14 with a dash character ; between them and a colon plus the drawing's SHEET ; assignment pasted on to the end, and all to go to ; TB-DNAM attribute the call would look like this: ; TB-DNAM=(tb_concatenate (list 3 "-" 14 ":" "SHEET")) ; Make sure linelst is not nil and is a list of something ; -- internal functions -- (defun reread_wd_m ( / ) ; make sure that have fresh copy of WD_M data in memory (setq GBL_wd_m nil) ; to force re-read ; read WD_M block and set GBL_wd_m global for this ; active dwg (c:wd_read_dwg_params) ; remember have read this dwg's WD_M data (setq fresh_wdm_in_memory 1) ) ; -- main program starts here -- (setq output_str "") ; default to nothing if total failure (if (AND linelst (listp linelst)) (progn ; okay to continue (setq fresh_wdm_in_memory nil) ; Get copy of the active project's title descriptions ; and drawing-specific data held in the project WDP file (setq x (c:wd_proj_wdp_data)) ; API call for proj data (setq desclst (nth 2 x)) ; strip out just LINEx list ; Save drawing list with SEC/SUBSEC and the three ; drawing description lines. (setq fulldwglst (nth 6 x)) ; Now assemble the concatenated output string (foreach item linelst (cond ((= (type item) 'INT) ; This parameter is an integer number value. ; Assume it maps to a project LINEx value (if (< item (length desclst)) ; check overrun ; Paste in this LINEx value into the output (setq output_str (strcat output_str (nth item desclst))) ) ) ; If parameter was a character string and not ; an integer number, check to see if it matches ; up with one of the drawing-specific codes. ((= item "DWGNAM") (if (not fresh_wdm_in_memory)(reread_wd_m)) ; Pull out the "%D" from dwg's config wd_m block (if GBL_wd_m (setq output_str (strcat output_str (nth 46 GBL_wd_m)))) ) ((= item "SHEET") (if (not fresh_wdm_in_memory)(reread_wd_m)) ; Pull out the "%S" from dwg's config wd_m block (if GBL_wd_m (setq output_str (strcat output_str (nth 13 GBL_wd_m)))) ) ((= item "IEC_P") (if (not fresh_wdm_in_memory)(reread_wd_m)) ; Pull out the "%P" from dwg's config wd_m block (if GBL_wd_m (setq output_str (strcat output_str (nth 51 GBL_wd_m)))) ) ((= item "IEC_I") (if (not fresh_wdm_in_memory)(reread_wd_m)) ; Pull out the "%I" from dwg's config wd_m block (if GBL_wd_m (setq output_str (strcat output_str (nth 52 GBL_wd_m)))) ) ((= item "IEC_L") (if (not fresh_wdm_in_memory)(reread_wd_m)) ; Pull out the "%L" from dwg's config wd_m block (if GBL_wd_m (setq output_str (strcat output_str (nth 53 GBL_wd_m)))) ) ((= item "DWGSEC") (if (AND fulldwglst GBL_wd_cip) (progn ; find match on drawing index (setq hit nil) (foreach x fulldwglst ; On dwg index match, pull out "SEC" value (if (= (car x) GBL_wd_cip)(setq hit (cadr x))) ) ; Add the "SEC" value to the output string (if hit (setq output_str (strcat output_str hit))) ) ) ) ((= item "DWGSUB") (if (AND fulldwglst GBL_wd_cip) (progn ; find match on drawing index (setq hit nil) (foreach x fulldwglst ; On dwg index match, pull out "SUBSEC" value (if (= (car x) GBL_wd_cip)(setq hit (caddr x))) ) ; Add the "SUBSEC" value to the output string (if hit (setq output_str (strcat output_str hit))) ) ) ) ((OR (= item "DWGDESC") (= item "DD1")) (if (AND fulldwglst GBL_wd_cip) (progn ; find match on drawing index (setq hit nil) (foreach x fulldwglst (if (= (car x) GBL_wd_cip)(setq hit (nth 4 x))) ) ; Add the "1st dwg desc" into the output string (if hit (setq output_str (strcat output_str hit))) ) ) ) ((OR (= item "DWGDESC2") (= item "DD2")) (if (AND fulldwglst GBL_wd_cip) (progn ; find match on drawing index (setq hit nil) (foreach x fulldwglst (if (= (car x) GBL_wd_cip)(setq hit (nth 6 x))) ) ; Add the "2nd dwg desc" into the output string (if hit (setq output_str (strcat output_str hit))) ) ) ) ((OR (= item "DWGDESC3") (= item "DD3")) (if (AND fulldwglst GBL_wd_cip) (progn ; find match on drawing index (setq hit nil) (foreach x fulldwglst (if (= (car x) GBL_wd_cip)(setq hit (nth 7 x))) ) ; Add the "3rd dwg desc" into the output string (if hit (setq output_str (strcat output_str hit))) ) ) ) (T ; assume delimiter or fixed text string (setq output_str (strcat output_str item)) ) ) ) ) ) output_str ; return the full string (or "" if failure) )