-
Coinciding with the acquisition of VIA Development, Nate joined Autodesk in March of 2003 after a decade stint as an entrepreneur following a two-decade stint as a controls engineer and software applications developer at Owens-Corning. Nate is now the lead product architect for AutoCAD Electrical. He loves this stuff.
-
AutoCAD Electrical's report customization - the 'User Post'
June 15, 2009, 07:53 AM Nate HoltWe've posted a number of times with specific examples of report 'User Posts'. Here is another but one that is given in much greater detail. This posting might better serve as template for creating your own customizations of AutoCAD Electrical's reports.
The Challenge
A European dealer had a customer who wanted his Cable From/To report to repeat the parent cable marker's catalog assignment for each and every child entry in the report.
For example, here is how a portion of the default report displays.

The problem for this user is that he wants to see the cable's catalog assignment show up for EVERY core/conductor displayed, not just the first 'parent' entry for the cable.
In the highlighted section above for cable tag-ID '-W5', the parent core/conductor carries the MFG/CAT catalog assignment (parent = 1 in the CBLP1C2 column). This shows up for the one line in the report for cable -W5. But the remaining child core/conductors (child = 2 in CBLP1C2 column) do not carry the parent's assignment and therefore their entries in the report show blank for the catalog assignment.
The customer wants all these filled in.
One work-around is to put the same catalog assignment on each child core/conductor of the cable. This will solve one problem (our Cable From/To report) but will then totally confuse the Bill of Materials report... we'll get a full cable BOM entry for every conductor/core found in a cable.
So, the only reasonable work-around is to create a "user post".
The Default User Post for the Cable From/To Report
There is a default user post AutoLISP utility for each AutoCAD Electrical report type. There is one for this Cable From/To report.
So, when the normal Cable From/To report displays, the user selects the "User Post" button on the lower right-hand corner of the report dialog.

This launches an AutoLISP utility "cablecon.lsp" and passes the block of report data (in form of "list of lists") to this cablecon.lsp utility. The location of this user post program file is displayed in the command window (shown below for ACE2008, subsequent releases have it in "c:\documents and settings\All Users\Documents\Autodesk\Acade 200x\Support\"). This user post utility immediately fires up and displays an options dialog as shown here.

Our challenge is to add a fourth option to this dialog: "Display catalog assignments on child entries"
Step 1 - Modify the dialog "DCL" file
Open the file cablecon.dcl with any ASCII text editor. This file should be in the same folder as the user post utility (path shown in command window above).
Make a back-up copy. Then carefully modify the original version. Add the fourth option as shown below and save the modified file.

That should now trigger a fourth toggle to display when the Cable From/To User Post is run. But this new toggle is not "hooked up" to anything. That's the next [more complicated] step.
Step 2 - Modify the cablecon.lsp file
Open up this file (path given above) with an ASCII text editor or with the Visual Lisp editor built into AutoCAD / AutoCAD Electrical. Page down a bit to the "main routine" section shown below. Add in the two lines of code as marked. These two lines make the initial link into the new toggle added to the dialog definition file in Step #1.
Now the meat of the addition...!
Page down to near the bottom of the cablecon.lsp file. Insert the new section as shown here:

Here is how the above is meant to work...
When the user selects the 4th toggle on the opening DCL dialog, it sets the "user_4" flag to a value of "1". This triggers this highlighted section of the utility to execute. The first "foreach..." makes an initial pass through each line of passed report data (in list "wd_rdata"). Here is how this first pass works, but a bit of explanation needed first.
The format of the report data is a list of sublists. Each sublist represents the data for a line in the report. Each line's sublist has about 70 or so elements. What each element means is given in a comment section shown at the top of the user post cablecon.lsp file and is reproduced below.
; -- Structure of the "wd_rdata" list of lists passed from ACE:
;
; (list (list <report line1 data>) (list <report line2 data>) ... )
; where each line data sublist consists of a list of the following:
; 0 = wire number
; 1 = LOC for "from" device
; 2 = TAG ID for "from" device
; 3 = terminal PIN number for "from" device connection
; 4 = LOC for "to" device
; 5 = TAG ID for "to" device
; 6 = terminal PIN number for "to" device connection
; 7 = WIRELAY for wire touching "from" device
; 8 = WIRELAY for wire touching "to" device
; 9 = line ref of "from" device
; 10= line ref of "to" device
; 11= SHEET number for "from" device
; 12= SHEET number for "to" device
; 13= cable marker - TAG ID (if cable marker present in wire)
; 14= cable marker - conductor color/number value
; 15= cable marker - LOC code
; 16= cable marker - MFG part number assignment
; 17= cable marker - CAT part number assignment
; 18= cable marker - ASSYCODE part number assignment
; 19= cable marker - catalog lookup DESC field value
; 20= cable marker - catalog lookup QUERY1 field value
; 21= cable marker - catalog lookup QUERY2 field value
; 22= cable marker - catalog lookup MISC1 field value
; 23= cable marker - catalog lookup MISC2 field value
; 24= cable marker - catalog lookup USER1 field value
; 25= cable marker - catalog lookup USER2 field value
; 26= cable marker - catalog lookup USER3 field value
; 27= cable marker - DESC1 description value assignment
; 28= cable marker - DESC2
; 29= cable marker - DESC3
; 30= cable marker - 1=parent marker, 2=child marker
; 31= TAG:PIN - combined "from" device text consisting of TAG ID and PIN number
; 32= TAG:PIN - combined "to" device text consisting of TAG ID and PIN number
; 33= SEC assignment for drawing with "from" device
; 34= SUBSEC assignment for drawing with "from" device
; 35= SEC assignment for drawing with "to" device
; 36= SUBSEC assignment for drawing with "to" device
; 37= INST assignment of "from" device
; 38= INST assignment of "to" device
; 39= IEC style name for "from" device
; 40= IEC style name for "to" device
; 41= TERMDESC value of "from" device wire connection point
; 42= TERMDESC value of "to" device wire connection point
; 43= wire connection sequence code for "from" device wire connection
; 44= wire connection sequence code for "to" device wire connection
; 45= PNLWDLEV1
; 46= PNLWDLEV2
; 47= CMPHDL1 = handle of the "from" component
; 48= CMPHDL2 = handle of the "to" component
; 49= DWGIX1 = the "from" component's drawing index number
; 50= DWGIX2 = the "to" component's drawing index number
; 51= DWGNAM1 = the %D drawing name value of the "from" drawing
; 52= DWGNAM2 = the %D drawing name value of the "to" drawing
; 53= handle of the cable marker
; 54= INST of the cable marker
; 55= CBLDWGIX drawing index number of the cable marker
; 56= entity name of the connected wire on "from" component
; 57= entity name of the connected wire on "to" component
; 58= wire connection direction of "from" component wire connection
; 59= wire connection direction of "to" component wire connection
; 60-62 = X,Y,Z of any associated "from" panel layout wire connection
; 63= "from" panel footprint representation wire connection direction
; 64-66 = X,Y,Z of any associated "to" panel layout wire connection
; 67= "to" panel footprint representation wire connection direction
; 68 = estimated wire length based upon 60-62 and 64-66So, our first pass needs to look for parent entries (index 30 in the sublist) that have non blank catalog assignments (index 17 in the sublist). For each one found in the first pass, it saves that line of data in a variable called "parent_lst".

Now, with all parent cable markers found, the utility makes a second pass through the lines of report data. It looks for "child" cable marker entries (value of "2" in the 30th index position) and makes sure that the child entry has no current assignment (the index 17 position is blank).
For each hit, it quickly looks for a parent match (from the "parent_lst" list collected in the first pass). If match on tag-ID and INST and LOC, then it pulls a copy of the parent's MFG/CAT/ASSYCODE and pushes it into the child's sublist (index positions 16,17, and 18).

The second pass builds a new, fresh copy of the list of sublists for the report (built in the variable called "rtrn"). The parent entries and children that have no parent match get pushed back into this new version of the data "as is". But the child entries that find a match get their modified version pushed into "rtrn". The version last line shown above replaces the original "wd_rdata" list of data with this modified version.
This new version of the report data is returned back to the report display dialog. That's about it. The dialog will now display the child entries with the MFG/CAT values filled in ( ! )

You must be logged in to post a comment.