"User Post" to alter sort of "By Tag" BOM

  • 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.

    About Nate

Latest Post

  • "User Post" to alter sort of "By Tag" BOM
    April 7, 2008, 03:06 PM Nate Holt

    This came up late last week. A European user was seeing his "By Tag" bill of materials report show up sorted in reverse order when the primary sort was set to be the "TAG" field. He was seeing BOM entry for "-91K" show up before the entry for "-51Q" or "-1X".

    It appears that this report is first attempting to sort on the numeric suffix value of the field before it tries an alphanumeric evaluation. So the leading "dash" character common in IEC tagging mode was making the tag values look like negative numbers. The result is that sorting negative numbers from small (most negative) to large (least negative) would put "-91" before "-15" and "-1".

    The work-around was to create a "User Post", launched from the "By Tag" BOM report display. This would "post-process" the report data, do an alphanumeric sort (instead of numeric sort) on the "Tag" field, and then re-display the report.

    It only took one line of code added to the existing "user post" AutoLISP utility that ships with the product. This extra line makes a call into an AutoCAD Electrical API "sort" function. It sorts on the "(nth 16 ...)" element of each "By Tag" BOM entry - which corresponds to the "TAG" field. 

          (if (= user_2 "1")
            (progn
              (setq combined_data (c:wd_selsort combined_data '(lambda (X Y) (< (nth 16 X)(nth 16 Y)))))
          ) )

    The ACE2008 path/filename is c:\program files\autodesk\acade 2008\tag_bom.lsp - for other versions, hit the "User post" button with the report displayed and observe the full path/filename given in the command window).

    To finish it off, the "Dialog" entry can be changed as well (same folder, file name tag_bom.dcl):

     :toggle{key="user2";
            label="Use alpha-sort on TAG column";
            }

    That's it. Seems to work.

    Download files here is you'd like this adjusted user post file.

    files/21201_21300/21282/file_21282.lsp   (rename tag_bom.lsp)

    files/21201_21300/21283/file_21283.dcl   (rename tag_bom.dcl)

    0 Comment | Add Comment Controlling the Machine >

Comments



You must be logged in to post a comment.

Subscribe to Blog

Want to keep up with the latest? Subscribe to the RSS feed today.

RSS

Tags

You must be logged in to add a tag.

Send to a Peer

You must login to share pages.

Feedback

Tell us what you think of the site.

Send Feedback