Inventor General Discussion

Reply
New Member
engr3
Posts: 1
Registered: ‎07-05-2011
Message 1 of 9 (2,260 Views)

ilogic: change BOM structure from normal to phantom

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

*Expert Elite*
Curtis_Waguespack
Posts: 2,840
Registered: ‎03-08-2006
Message 2 of 9 (2,243 Views)

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.





Mentor
mehatfie
Posts: 163
Registered: ‎02-10-2012
Message 3 of 9 (1,946 Views)

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

Mentor
mehatfie
Posts: 163
Registered: ‎02-10-2012
Message 4 of 9 (1,941 Views)

Re: ilogic: change BOM structure from normal to phantom

03-08-2012 06:16 AM in reply to: mehatfie
*Pro
jletcher
Posts: 1,946
Registered: ‎05-18-2011
Message 5 of 9 (1,844 Views)

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 :-(
*Expert Elite*
Curtis_Waguespack
Posts: 2,840
Registered: ‎03-08-2006
Message 6 of 9 (1,836 Views)

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.





New Member
ansv
Posts: 1
Registered: ‎06-11-2012
Message 7 of 9 (1,769 Views)

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.

 

 

Valued Contributor
nandakumar.hegde
Posts: 56
Registered: ‎05-25-2005
Message 8 of 9 (1,421 Views)

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

 

Valued Contributor
nandakumar.hegde
Posts: 56
Registered: ‎05-25-2005
Message 9 of 9 (1,415 Views)

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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube