I'm using rules to control a part that I made. This part is available in steel and wood.
But steel = normal and wood is something we have to buy.
I would like to adjust my rule so that my material choice will effect the "Default BOM Structure"
I just can't find the right "code" to start with.
I would like to do this on part level.
Thanks.
Solved! Go to Solution.
Solved by cwhetten. Go to Solution.
Niels van der Veer
Inventor professional user & 3DS Max enthusiast
Vault professional user/manager
The Netherlands
This is what i could find in the programming help:
Parent Object: PartComponentDefinition
Gets and sets how the component is used/viewed in a BOM.
PartComponentDefinition.BOMStructure() As BOMStructureEnum
Introduced in Inventor version 10
I'm not much of a programmer, so just trying to help you find what you need.
Hope this helps.
Niels van der Veer
Inventor professional user & 3DS Max enthusiast
Vault professional user/manager
The Netherlands
Can you post your iLogic rule here? It would be very helpful in helping us understand exactly what you need to do. With programming, context is everything. I think I can help you, but I need more information.
Cameron Whetten
Inventor 2014
This was the code I found.
I like to change the BOM status in the Document Settings on part level. (see attachment)
doc = ThisDoc.Document def = doc.ComponentDefinition thebom = def.BOM thebomview= thebom.BOMViews(1) thebomrow = thebomview.BOMRows(1) thebomrow.BOMStructure = 51971 'kPhantomBOMStructure
and this
Public Enum BOMStructureEnum kDefaultBOMStructure = 51969 kNormalBOMStructure = 51970 kPhantomBOMStructure = 51971 kReferenceBOMStructure = 51972 kPurchasedBOMStructure = 51973 kInseparableBOMStructure = 51974 kVariesBOMStructure = 51975 End Enum
Try something like this:
oMaterial = iProperties.Material Select Case oMaterial Case "Steel" ThisDoc.Document.ComponentDefinition.BOMStructure = BOMStructureEnum.kNormalBOMStructure Case "Wood" ThisDoc.Document.ComponentDefinition.BOMStructure = BOMStructureEnum.kPurchasedBOMStructure End Select
This should work to switch the BOM structure at the part level. However, this rule won't automatically run when you change the part material. You will have to do something extra to get it to automatically run. The easiest would be to set an event trigger for "Material Change" (see the image below).
If that doesn't work, there are other ways.
Cameron Whetten
Inventor 2014
Please click "Accept as Solution" if this response answers your question.
Thanks
I got it to work.
There was no need to set the trigger. It changed every time I choose a different material. Here is my final code:
(Some text is in norwegian but Treverk = wood, Stål = staal, Rusftfritt = stainless)
If Material = "Treverk" Then MultiValue.SetList("Diameter", "Ø 40 treverk","Ø 50 treverk") Diameter = "Ø 40 treverk" End If If Material = "Syrefast" Or Material = "Stål" Or Material = "Rustfritt" MultiValue.SetList("Diameter", "Ø 33,7","Ø 42,4") Diameter = "Ø 42,4" End If If Diameter = "Ø 42,4" Then diameter = 42.4 ElseIf Diameter = "Ø 33,7" diameter = 33.7 ElseIf Diameter = "Ø 40 treverk" diameter = 40 ElseIf Diameter = "Ø 50 treverk" diameter = 50 End If If Material = "Rustfritt" Then thickness = 2 rm = 74 iProperties.Value("Project", "Stock Number")= "RF RØR " & diameter &"x"& thickness Feature.Color("Sweep1")= "Stainless - Brushed" Feature.Color("Sweep2")= "Stainless - Brushed" Feature.Color("Sweep3")= "Stainless - Brushed" iProperties.Material = "AISI304" ElseIf Material = "Syrefast" Then thickness = 2 rm = 74 iProperties.Value("Project", "Stock Number")= "RF RØR " & diameter &"x"& thickness Feature.Color("Sweep1")= "Stainless - Brushed" Feature.Color("Sweep2")= "Stainless - Brushed" Feature.Color("Sweep3")= "Stainless - Brushed" iProperties.Material = "AISI316" ElseIf Material = "Stål" Then thickness = 2.6 mm rm = 74 mm iProperties.Value("Project", "Stock Number")= "RØR " & diameter &"x"& thickness Feature.Color("Sweep1")= "Turquoise" Feature.Color("Sweep2")= "Turquoise" Feature.Color("Sweep3")= "Turquoise" iProperties.Material = "S235JR" ElseIf Material = "Treverk" Then thickness = diameter/2-1 rm = diameter/2 iProperties.Value("Project", "Stock Number")= "Treverk " & diameter Feature.Color("Sweep1")= "Wild Cherry - Groove" Feature.Color("Sweep2")= "Wild Cherry - Groove" Feature.Color("Sweep3")= "Wild Cherry - Groove" iProperties.Material = "Wood" End If If Bend = "1 bend" Then Feature.IsActive("Sweep2") = False Feature.IsActive("Sweep3") = False Kapp = Topp + Skrå ElseIf Bend = "2 bend" Then Feature.IsActive("Sweep2") = False Feature.IsActive("Sweep3") = True Kapp = Topp + Skrå + Bunn ElseIf Bend = "2 bend paralel" Then Feature.IsActive("Sweep2") = True Feature.IsActive("Sweep3") = False Kapp = Topp + Skrå + Bunn End If oMaterial = iProperties.Material Select Case oMaterial Case "S235JR" ThisDoc.Document.ComponentDefinition.BOMStructure = BOMStructureEnum.kNormalBOMStructure Case "AISI304" ThisDoc.Document.ComponentDefinition.BOMStructure = BOMStructureEnum.kNormalBOMStructure Case "AISI316" ThisDoc.Document.ComponentDefinition.BOMStructure = BOMStructureEnum.kNormalBOMStructure Case "Wood" ThisDoc.Document.ComponentDefinition.BOMStructure = BOMStructureEnum.kPurchasedBOMStructure End Select
Excellent! I'm glad it worked for you. I see that you are using a user parameter to select the material. By default, iLogic rules will run automatically if a parameter that they contain changes value. So that is why it automatically runs for you without the event trigger.
Using a user parameter was going to be my second suggestion in lieu of using event triggers.
Cameron Whetten
Inventor 2014