Nate Holt's Blog

June 28, 2010

Sorting BOM report on USER1 field – AutoCAD Electrical

Filed under: Electrical — nateholt @ 5:25 pm

How to create a BOM “user post” to map the report’s USER1 values into a field that can be selected for sorting.

A limitation with AutoCAD Electrical’s BOM report display dialog is that it is only set up to allow sorting on just a handful of the possible display fields.

For example, a “Tallied BOM Report” for panel layout shows there are only four fields available for sorting: ITEM, CATALOG, MFG, and TABNAM where TABNAM refers to the catalog lookup database table name.

But let’s say that you really, really, REALLY want to sort on the report’s USER1 field value. You’ve set USER1 up in the catalog lookup database file (default_cat.mdb) to carry your company’s internal part codes. The existing CAT and MFG field values will carry the vendor part number… but you really want your report sorted by these USER1 internal part number codes.

If you really want to do this, here’s how. It ain’t pretty… but it works.

The workflow will be to select the “User Post” button. It will have a new option (that we’re going to add shortly) that pre-processes the BOM report data. For each line in the BOM, it finds the USER1 field value and copies it over into the rarely used TABNAM field. Now, we sort on this TABNAM field (which is one of the four supported sort fields and now actually carries a copy of the USER1 field values). The net effect is that our displayed BOM report now appears to be sorted on the USER1 field values ( ! ).

We have to alter the two support files for the tallied panel BOM report. These are the small dialog file pnlbom.dcl and the AutoLISP utility pnlbom.lsp. Use any ASCII text editor or use the Visual Lisp editor built into AutoCAD (type VLIDE [Enter] at the command prompt).

Important: Before you start, make BACKUPs of both files… just in case ( ! )

Here is the change for pnlbom.dcl edit:

And here is the bompnl.lsp file. There should be a comment section that describes the structure of the report data list that is used to drive the report dialog. We find the two items that we’re interested in… the existing “TABNAM” field position in the list and the “USER1” field position in the list. We want to take a copy of the USER1 value in each line of the list and dump it into the TABNAM value in the list.

Now, using the 12th and 15th positions determined above, here are the bompnl.lsp file additions (highlighted in yellow).

Applying to other BOM reports?

Question: Can I do this to some other BOM report?  Answer: Yes, just follow the above example and make similar changes in the other BOM report’s user post “.lsp” and “.dcl” files… it should work.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: