• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor

    Reply
    Active Member
    Posts: 8
    Registered: ‎10-31-2009

    iLogic to Sort BOM, Renumber and sort Parts list

    1317 Views, 7 Replies
    06-13-2011 01:39 AM

    I want to use iLogic to:

    1.Sort an assembly BOM by Part Number.

    2. Renumber Items in the BOM as sorted.

    3. Sort a drawing Parts list by item number.

     

    The background to my problem is that i have an assembly which is working beautifully turning components on and off (suppressing/activating in LOD reps) as defined by iLogic rules (iLogic is awesome). The problem is whenever a part is turned on/activated again, it shows up at the bottom of the BOM and Parts list out of order (would be nice if parts went back in the list where they came from). I can do all this manually but I have to do it often and would love to improve efficiency and I sometimes forget when in a hurry.

     

    Any help/code for this would be greatly appreciated.

    Please use plain text.
    *Expert Elite*
    Curtis_Waguespack
    Posts: 1,964
    Registered: ‎03-08-2006

    Re: iLogic to Sort BOM, Renumber and sort Parts list

    06-14-2011 08:17 AM in reply to: ifsi

    Hi ifsi,

     

    You can find an example of how to do this at this link:

    http://inventortrenches.blogspot.com/2011/02/ilogic-code-for-parts-lists-title.html

     

    Note that in the example there are three lines as such:

     

    oPartsList1.Sort("PART NUMBER")
    'oPartsList1.Renumber
    'oPartsList1.SaveItemOverridesToBOM

    

    The Renumber and SaveItemOveridesToBOM lines are commented so, you'll want to remove the apostrophe to uncomment them and let those line become active.

     

     I hope this helps.

     

    Best of luck to you in all of your Inventor pursuits,

    Curtis

    http://inventortrenches.blogspot.com/

      

     



      solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.

    Please use plain text.
    Active Member
    Posts: 8
    Registered: ‎10-31-2009

    Re: iLogic to Sort BOM, Renumber and sort Parts list

    06-14-2011 05:47 PM in reply to: Curtis_Waguespack

    Pure gold! Thank you Curtis

    Please use plain text.
    Member
    SPrice33
    Posts: 5
    Registered: ‎04-05-2011

    Re: iLogic to Sort BOM, Renumber and sort Parts list

    08-24-2011 08:00 AM in reply to: ifsi

    That code is working great, but I was curious to see if anyone had any idea as to how to get the parts list to sort by multiple fields instead of just the Part Number.  I can't seem to find what the proper API would be for the 2nd level of sorting.  Ideally I would like to have the parts list sort by...

     

    1st) "Allocation"  - (Allocation will be listed as "loose" or "installed" hardware)

    2nd) "Bench" - (Bench will be listed as either "B" or "-")

     

     

    Please use plain text.
    *Expert Elite*
    Curtis_Waguespack
    Posts: 1,964
    Registered: ‎03-08-2006

    Re: iLogic to Sort BOM, Renumber and sort Parts list

    08-24-2011 08:44 AM in reply to: SPrice33

    Hi SpencerPrice33,

     

    If you need to sort a parts list by multiple columns you can use something like this:

    Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.ActiveDocument
    Dim oPartsList1 As PartsList
    oPartsList1 = oDrawDoc.ActiveSheet.PartsLists.Item(1)
    oPartsList1.Sort("DESCRIPTION", 1, "QTY", 1)

     

    This results in the parts list sorting first by the DESCRIPTION column and then the QTY column in ascending order. You can use 0 for the sort Boolean to sort by descending order. For example:

    Dim oDrawDoc As DrawingDocument
    oDrawDoc = ThisApplication.ActiveDocument
    Dim oPartsList1 As PartsList
    oPartsList1 = oDrawDoc.ActiveSheet.PartsLists.Item(1)
    oPartsList1.Sort("DESCRIPTION", 0, "QTY", 0)
     


    I hope this helps.
    Best of luck to you in all of your Inventor pursuits,
    Curtis
    http://inventortrenches.blogspot.com


      solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.

    Please use plain text.
    Member
    SPrice33
    Posts: 5
    Registered: ‎04-05-2011

    Re: iLogic to Sort BOM, Renumber and sort Parts list

    08-24-2011 10:06 AM in reply to: Curtis_Waguespack

    Great!  Thank you so much!  I thought I had tried that earlier and it didn't work - must have missed something tiny...

    Please use plain text.
    Active Contributor
    vishgon
    Posts: 27
    Registered: ‎02-28-2007

    Re: iLogic to Sort BOM, Renumber and sort Parts list

    12-04-2012 08:01 PM in reply to: Curtis_Waguespack

    Curtis

     

    Is it possible to sort the BOM while ignoring rows that have their item numbers locked. As an extension to that is it possible to lock the rows for selected item, e.g. select items before running ilogic rule and hence ilogic ignores those items in the BOM

    Please use plain text.
    New Member
    Posts: 1
    Registered: ‎02-18-2013

    Re: iLogic to Sort BOM, Renumber and sort Parts list

    02-18-2013 02:12 PM in reply to: Curtis_Waguespack

    Hello, Curtis,

    I need some help. I tried to run your script, but I must not know how to set it up correctly because I can't get it to run. I am new to using scripts/iLogic. Are you availabe as a consultant? We have a need for some scripts and how to access them.

    Please use plain text.