Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ilogic: change BOM structure from normal to phantom

10 REPLIES 10
Reply
Message 1 of 11
engr3
7807 Views, 10 Replies

ilogic: change BOM structure from normal to phantom

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.

10 REPLIES 10
Message 2 of 11
Curtis_Waguespack
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/

 

 

 

Message 3 of 11

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

Message 4 of 11
mehatfie
in reply to: mehatfie

Message 5 of 11

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?

Message 6 of 11

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

 

 

 

Message 7 of 11
ansv
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.

 

 

Message 8 of 11

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

 

Message 9 of 11

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

Message 10 of 11
Jefkee
in reply to: nandakumar.hegde

Hi,

 

is it possible to use the rule based on browser name?

 

Component.InventorComponent("Nozzle 001").BOMStructure = 51971

 

It's not working for me.. not sure what is wrong..

Inventor 2013
Message 11 of 11
Curtis_Waguespack
in reply to: Jefkee

Just a link to related thread, with some examples that set the BOM structure for a named component,  in case it helps someone in the future:

 

http://forums.autodesk.com/t5/inventor-general-discussion/using-ilogic-to-to-control-bom-structure-i...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report