-
Controlling the Machine is no longer being updated. Don't worry, though, you can still follow Nate Holt at his new blog, AutoCAD Electrical Etcetera. You'll find it at http://nateholt.wordpress.com. Or you can subscribe to his feed to get latest words of wisdom automatically: http://nateholt.wordpress.com/feed/. You also can continue to view the Controlling Machine archives for Nate's AutoCAD Electrical tips and tricks.
-
Drawing List report and 'user post' example - AutoCAD Electrical
February 19, 2008, 09:23 AM Nate HoltNearly all of AutoCAD Electrical's reports can be reformatted on-the-fly with a custom 'user post'. It requires some setup but can fill in the gap between what ACE supplies out-of-the-box and what your specific needs might be.
Here is a recent example. A user wanted to run the 'Drawing List' report but then insert a blank spacer line into the report whenever a specific field value changed from one line to the next. In the report display below, every time the "Section" value changes, we'd like a blank spacer line inserted into the report. So, a blank line to show up with each change in the "Contract x" number.

The key to making this work is to tie in to the 'User Post' function. The button is in the the lower right-hand corner of the display dialog:

This will search for and launch an AutoLISP utility that matches up with the report type being displayed. Hit the button and then look at your command window. The path to the AutoLISP utility should be there:

Now the hard(er) part
You need to open up the dwglst.lsp file with an ASCII text editor or the built-in Visual Lisp editor (make a back-up copy first!).
Right now, the file is just a blank template. It has three user options but none of them are set up to do anything. Here is the key part of the post-processing utility program. It is just a place-holder for where we will start to add our own custom code:

The report data comes across in variable "wd_rdata". The format of this data for this "Drawing List" report is this:
; -- Structure of the "wd_rdata" list of lists passed from AutoCAD Electrical:
;
; (list (list <report line1 data>) (list <report line2 data>) ... )
; 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 fileSince we're interested in tracking the value of the "Section" value from one drawing to the next, we need to focus in on the index 5 position of each line of data.
So, coding this up, we might end up with this new code inserted into the above place-holder:

Our code grabs the "Sec" value from the first line of report data. Then it cycles through all lines of the report. Whenever the "Sec" value changes, it pushes in a "blank" line into the report.
Here's our new report display after selecting the "User post" button and picking the first option on the user post subdialog:

Here's a copy of this sample user post utility and the companion "dcl" dialog file.
files/20801_20900/20884/file_20884.lsp (rename to dwglst.lsp)
files/20801_20900/20885/file_20885.dcl (rename to dwglst.dcl)
Comments
-
January 6, 2009 05:38 PM Mirko Prekoplotic
This worked out great for me. Thank you. I have modified your code to create blank line and place SEC string to DWGDESC each time SEC changes. SEC column is not displayed. This way you can get "title" for each section. Do you guys know how to underline text? I would like the "title" to be underlined. Here's the modified code: (progn (setq rtrn nil) ; Build up a "blank line" entry (setq blank nil) (setq blank_line nil) ; make equal in length to first line of data (repeat (length (car wd_rdata)) (setq blank (cons "" blank)) (setq blank_line (cons "" blank_line)) ) ; If line totally blank, report will filter it out. ; Add a dash in 5th index position. (setq blank (wd_nth_subst 7 "-" blank)) (setq blank_line (wd_nth_subst 3 "-" blank_line)) ; Get first line's SHDWGNAM value (setq doing_sec_value (nth 5 (car wd_rdata))) (setq blank (wd_nth_subst 7 doing_sec_value blank)) (setq rtrn (cons blank rtrn)) ; 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. ; Add a section name to blank line above description (setq blank (wd_nth_subst 7 (nth 5 xx) blank)) (setq blank_line (wd_nth_subst 3 "." blank_line)) (setq rtrn (cons blank_line rtrn)) ; insert blank line (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)
You must be logged in to post a comment.