; Copyright (C) 2002, 2003 by Autodesk, Inc. ; ; Permission to use, copy, modify, and distribute this software ; for any purpose and without fee is hereby granted, provided that ; the above copyright notice appears in all copies and that both ; the copyright notice and the limited warranty and restricted rights ; notice below appear in all supporting documentation. ; ; AUTODESK, INC. PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. ; AUTODESK, INC. SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF ; MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. ; DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE ; UNINTERRUPTED OR ERROR FREE. ; ; Use, duplication, or disclosure by the U.S. Government is subject to ; restrictions set forth in FAR 52.227-19 (Commercial Computer ; Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) ; (Rights in Technical Data and Computer Software), as applicable. ; ; 26-Sep-03 Mauro Sist globalized ; ** 29-Sep-02 NEHolt adjusted for calling from either VIA-WD Add-on or Stand Alone. Stand ; Alone requires that only one overall routine is defined, must be called "_wd_post_main". ; Any subroutines defined in this file MUST be defined internal to this main routine. ; ** 04-Jul-01 NEHolt N8 Solutions, Inc / VIA Development. Created ; as sample post-process util ; --------- D W G L S T . L S P ----------------------------- ; ; This routine is called from AutoCAD Electrical's "User post" button on the ; Drawing List report dialog display. Report data is passed to this ; routine in AutoLISP variable called "wd_rdata". This utility can ; then operate on this report data, reformat it into a new list of ; report data "rtrn" and then pass it back to AutoCAD Electrical's report dialog ; through a call to (c:wd_rtrn_2wd rtrn) shown at the end of this file. ; ; -- Structure of the "wd_rdata" list of lists passed from AutoCAD Electrical: ; ; (list (list ) (list ) ... ) ; where each line data sublist consists of a list of the following: ; 0 = drawing file name (no path, no extension) ; 1 = date stamp ; 2 = time stamp ; 3 = SHEET assignment (the %S value) ; 4 = SHDWGNAME assignment (the %D value) ; 5 = SEC assignment (the %A value) ; 6 = SUBSEC assignment (the %B value) ; 7 = Drawing desc line 1 ; 8 = Full file name ; 9 = Drawing desc line 2 ; 10 = Drawing desc line 3 ; 11 = IEC-Project (the %P value) ; 12 = IEC-Installation (the %I value) ; 13 = IEC-Location (the %L value) ; 14-?? = other values defined in ".wdt" title block attribute mapping file (defun _wd_post_main ( / rtrn dclnam dcl_id user_1 user_2 user_3 cancel xx wlay1 lay_map_lst data wd_make_dcl wd_nth_subst) ; -- internal subroutines (defun wd_nth_subst ( n val lst / newlst ix slen x ) ; Substitute the nth member of a list "lst" with new value "val" ; If "n" is past end of existing list then blank positions "nil" padded (if (not lst) (setq slen 0) (setq slen (length lst)) ) (cond ((minusp n) ) ; rtrn orig list if pos is neg number ((zerop n) (setq lst (cons val (cdr lst)))) ; n=0, replace 1st item ((= n slen) (setq lst (append lst (list val)))) ; new last item ((< n slen) ; Insert item somewhere else in list (setq ix 0) (setq newlst '()) (foreach x lst (if (/= ix n) (setq newlst (cons x newlst)) ; reuse existing (setq newlst (cons val newlst)) ; substitute new ) (setq ix (1+ ix)) ) (setq lst (reverse newlst)) (setq newlst nil) ) ((> n slen) ; lengthen list, add "nil" pads as req'd (setq lst (reverse lst)) (while (< slen n) (setq lst (cons nil lst)) ; add pads (setq slen (1+ slen)) ) (setq lst (reverse (cons val lst))) ; tack new item on end ) ) lst ) ; -- main routine -- (setq rtrn nil) ; AutoCAD Electrical passes the report displayed data as a list of lists of lists in variable ; called wd_rdata. The first element of this list is the list of lists ; report data. The 2nd element is future (at this time). (if (AND wd_rdata (car wd_rdata) (listp (car wd_rdata))) (setq wd_rdata (car wd_rdata))) ; just go with first list of lists (report data) ; Look for dcl file of same name, open if found. (setq cancel nil) (if (setq dclnam (c:ace_find_file "dwglst.dcl" 16)) ; 16=display error dialog if file not found (progn (setq dcl_id (load_dialog dclnam)) (if (new_dialog "main_select" dcl_id) (progn (setq user_1 "0") ; default to 1st user entry toggled on (setq user_2 "0") (setq user_3 "0") (set_tile "user1" user_1) ; preset toggle ON (action_tile "user1" "(setq user_1 $value)") (action_tile "user2" "(setq user_2 $value)") (action_tile "user3" "(setq user_3 $value)") (action_tile "cancel" "(setq cancel 1)") (start_dialog) (unload_dialog dcl_id) ) ) ) ) (if (AND wd_rdata (not cancel)) (progn ; user didn't cancel out of dialog, okay to continue (if (= user_1 "1") (progn (setq rtrn nil) ; Build up a "blank line" entry (setq blank nil) ; make equal in length to first line of data (repeat (length (car wd_rdata)) (setq blank (cons "" blank)) ) ; If line totally blank, report will filter it out. ; Add a dash in 5th index position. (setq blank (wd_nth_subst 5 "-" blank)) ; Get first line's SHDWGNAM value (setq doing_sec_value (nth 5 (car wd_rdata))) ; Now scan through the report data. ; Each time the SECTION value changes, insert ; a copy of the blank line into the report data. (foreach xx wd_rdata (if (/= (nth 5 xx) doing_sec_value) (progn ; this line has different value. Insert blank. (setq rtrn (cons blank rtrn)) ; insert blank line (setq rtrn (cons xx rtrn)) ; insert new line ; Remember the new "Sec" value being processed. (setq doing_sec_value (nth 5 xx)) ) ; ELSE (progn ; no SECTION change, just output original data (setq rtrn (cons xx rtrn)) ) ) ) ; Put report back into original order (setq rtrn (reverse rtrn)) ; Copy to original variable name for ; possible additional processing below. (setq wd_rdata rtrn) ) ) (if (= user_2 "1") (progn (princ (strcat "\n " (c:wd_msg "WLAY031" (list "2" "dwglst.lsp") "Nothing defined for user%1 option (see %2)")) ) ) ) (if (= user_3 "1") (progn (princ (strcat "\n " (c:wd_msg "WLAY031" (list "3" "dwglst.lsp") "Nothing defined for user%1 option (see %2)")) ) ) ) ) ) (c:wd_rtrn_2wd rtrn) ; return post-processed list back to AutoCAD Electrical's report dialog ) ; -- the following AUTO-STARTS when this file is "loaded" from within AutoCAD Electrical (i.e. ; user hits the "User post" button on a report display dialog) (_wd_post_main) ; run the above program (princ)