Tick Talk on EsoxRepublic.com


SW BOM to Excel Macro

Posted in API, Esox Software by Administrator on the September 11th, 2008

…not quite, but a fast way from here to there.

I just released a macro I have been using for a few months. “Copy BOM to Clipboard” macro does exactly what it says: it copies a table-style BOM from a SW drawing to the clipboard in a format that can readily be pasted into MS Excel. Download here.

Just run the macro with a SW drawing open. If successful, there will be a message like that shown below. Then go to an Excel worksheet, select a cell, and paste (”ctrl-v”).

BOM to Clipboard message window
Message box indicating successful acquisition of BOM.

Developer’s notes

It’s been a while, but I am trying to remember some of the specific challenges of writing this. It took about two hours of fumbling until the error-to-trial ratio dropped below 1.0.

Application writing is often mostly about validation. Checking to see if there is an active document, is it a drawing, does it have a BOM (or more than one). That took most of the time.

There was a hook to getting ahold of the table data. I put the BOM data first into a SldWorks.BomTableAnnotation object, then moved it to a SldWorks.TableAnnotation object which could then be parsed into an array. The final array is then written to a tab-delimited string which pastes so nicely into Excel.

It could have been more elegant, but it “works fine, lasts long time”.

Thought for the day

Speak softly and carry a big stick. Some folks out there can take a punch much better than they can take an insult.

Leave a Reply

You must be logged in to post a comment.