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

    Autodesk Inventor

    Reply
    New Member
    engr3
    Posts: 1
    Registered: ‎07-05-2011

    ilogic: change BOM structure from normal to phantom

    1145 Views, 8 Replies
    07-05-2011 12:51 PM

    I need help on a rule in ilogic that changes BOM Structure in the Bill of Materials from normal to phantom from a paramater that allows the user to select "Standard",  "Custom A" ,or "Custom B". If "Standard" is selected the component will have a "normal" BOM structure in the bill of materials. However, if "Custom A" is selected the same component will appear as "phantom". I understand how to use an if-then statement to select the standard or custom parmeter, I just need help on the piece of code that lets me select and change the BOM structure for specific components.

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

    Re: ilogic: change BOM structure from normal to phantom

    07-05-2011 03:04 PM in reply to: engr3

    Hi engr3,

     

    Here is a bit of sample code that demonstrates how to do this. Keep in mind that when you set the BOM structure of a component in this way, you are setting it for the component file, not just the component occurrence. Therefore if you set Bolt55.ipt to be phantom in the current assembly, it would change in every assembly BOM it is used in.

     

    Of course you can locate a component occurrence in the browser, then right click and choose BOM Structure > Reference and that will set just that occurrence to be Reference, but I could not find a way to do this with iLogic. I may have simply missed something though.

     

    Here is the iLogic code:

     

    Dim compOcc as ComponentOccurrence
    
    Try
      compOcc = ThisDoc.Document.SelectSet.Item(1)
    Catch
      MessageBox.Show("You must select a component before running this rule.", "iLogic")
      Return
    End Try
    
    Dim oStandard as Object
    oStandard= InputRadioBox("Select One", "Standard (normal)", "Custom (phantom)", oStandard, Title := "iLogic")
    
    'Default = 51969
    'Normal = 51970
    'Phantom = 51971
    'Reference = 51972
    'Purchased = 51973
    'Inseparable = 51974
    'Varies = 51975
    
    If oStandard = True then
    compOcc.Definition.BOMStructure = 51970 'normal
    else
    compOcc.Definition.BOMStructure = 51971 'phantom
    end if
    
    'open BOM editor dialog box
    Dim oCtrlDef As ControlDefinition
    oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyBillOfMaterialsCmd")
    oCtrlDef.Execute

     

     

    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.
    Mentor
    mehatfie
    Posts: 163
    Registered: ‎02-10-2012

    Re: ilogic: change BOM structure from normal to phantom

    03-08-2012 06:11 AM in reply to: Curtis_Waguespack

    Hi Curtis,

     

    Is it possible to do this by hardcoding which part to change, rather then have the user select it? I would know how to change the BOM to reference from the code you've posted, but I'm not sure how to ichoose which part through code.

     

    Thanks

    Mitch

    Please use plain text.
    Mentor
    mehatfie
    Posts: 163
    Registered: ‎02-10-2012

    Re: ilogic: change BOM structure from normal to phantom

    03-08-2012 06:16 AM in reply to: mehatfie
    Please use plain text.
    *Pro
    jletcher
    Posts: 1,328
    Registered: ‎05-18-2011

    Re: ilogic: change BOM structure from normal to phantom

    05-25-2012 08:14 AM in reply to: Curtis_Waguespack

    oh how I needed this. but is there a way instead of it only doing it for one item is there a way to change it to a selection of parts? Like if I have 20 parts I want to change?


    Please mark this response as "Accept as Solution" if it answers your question.

    James Letcher
    2012 Factory Design Suite ( will not load 2013)
    What happen to my Inventor :-(
    Please use plain text.
    *Expert Elite*
    Curtis_Waguespack
    Posts: 1,955
    Registered: ‎03-08-2006

    Re: ilogic: change BOM structure from normal to phantom

    05-25-2012 10:10 AM in reply to: jletcher

    Hi jletcher, 

     

    Are these 20 parts all in one assembly? If so you can use the code posted below.  If not, I suppose you could select the parts in Windows Explorer and then drag and drop them into a new assembly file, then run the rule.

     

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


     

    'create list
    oStringArray = new string(){"Normal", "Phantom", "Reference", "Purchased", "Inseparable"}

    'Normal = 51970
    'Phantom = 51971
    'Reference = 51972
    'Purchased = 51973
    'Inseparable = 51974

    'get input from user
    oList = InputListBox("Select a type", oStringArray, "Normal", "iLogic", "Available BOM Structure")

    'define BOM Structure to use
    Dim oBOMStructure as Object
    If oList = "Normal" Then
    oBOMStructure = 51970
    Else if oList = "Phantom" Then
    oBOMStructure = 51971
    Else if oList = "Reference" Then
    oBOMStructure = 51972
    Else if oList = "Purchased" Then
    oBOMStructure = 51973
    Else if oList = "Inseparable" Then
    oBOMStructure = 51974
    Else
    End if


    ' set a reference to the assembly component definintion.
    ' This assumes an assembly document is open.
    Dim oAsmCompDef As AssemblyComponentDefinition
    oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

    'set the Master LOD active
    Dim oLODRep As LevelofDetailRepresentation
    oLODRep = oAsmCompDef.RepresentationsManager.LevelOfDetailRepresentations.Item("Master")
    oLODRep.Activate

    'Iterate through all of the occurrences
    Dim oOccurrence As ComponentOccurrence
    For Each oOccurrence In oAsmCompDef.Occurrences
    'set BOM Structure
    oOccurrence.Definition.BOMStructure = oBOMStructure
    Next

    'open BOM editor dialog box
    Dim oCtrlDef As ControlDefinition
    oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("AssemblyBillOfMaterialsCmd")
    oCtrlDef.Execute

     

     

     



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

    Please use plain text.
    New Member
    Posts: 1
    Registered: ‎06-11-2012

    Re: ilogic: change BOM structure from normal to phantom

    06-11-2012 03:31 AM in reply to: Curtis_Waguespack

    Hi all,

     

    Great info.

     

    oPartDoc = ThisDoc.Document
    r=oPartDoc.ComponentDefinition.BOMStructure

     I'm trying to apply the code above for IAM. But I'm getting error: member of the group is not found (DISP_E_MEMBERNOTFOUND) (my free translation).

     

    Any ideas how the code should be modified to be applecable to IAM?

     

    Just in case it makes difference - I'm using Inventor 2012.

     

    Sergey.

     

     

    Please use plain text.
    Valued Contributor
    Posts: 56
    Registered: ‎05-25-2005

    Re: ilogic: change BOM structure from normal to phantom

    01-03-2013 10:15 AM in reply to: Curtis_Waguespack

    hi,

    I want to convert all part/assembly to "Normal". I need this because I want to export all level to excel.

    If there is code to make it. it realy helps me lot.

     

    thanks,

    Nanda

     

    Please use plain text.
    Valued Contributor
    Posts: 56
    Registered: ‎05-25-2005

    Re: ilogic: change BOM structure from normal to phantom

    01-03-2013 10:43 AM in reply to: Curtis_Waguespack

    hi,

    I tried this on my assembly, it changes only only on main level. But I want to change all parts to Normal at all level.

    My assembly may have 9 level.

     

    But it is a grat code.

     

    thanks,

    Nanda

    Please use plain text.