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: 

Change BOM Structure with iLogic

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
Anonymous
4472 Views, 8 Replies

Change BOM Structure with iLogic

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.

8 REPLIES 8
Message 2 of 9
-niels-
in reply to: Anonymous

Does this topic help any?
I did a search on the forum for "BOMStructureEnum" and this seemed somewhat similar...
http://forums.autodesk.com/t5/Inventor-Customization/bom-structure-FromNormal-to-Phantom/m-p/3604844...

Niels van der Veer
Inventor professional user & 3DS Max enthusiast
Vault professional user/manager
The Netherlands

Message 3 of 9
Anonymous
in reply to: -niels-

I get an error when I try that:
(translated: Bom for type PartCompenentDefinition not found)
Message 4 of 9
-niels-
in reply to: Anonymous

This is what i could find in the programming help:

Spoiler

PartComponentDefinition.BOMStructure Property

Parent Object: PartComponentDefinition

Description

Gets and sets how the component is used/viewed in a BOM.

Syntax

PartComponentDefinition.BOMStructure() As BOMStructureEnum

Version

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

Message 5 of 9
cwhetten
in reply to: Anonymous

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

Message 6 of 9
Anonymous
in reply to: cwhetten

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
Message 7 of 9
cwhetten
in reply to: Anonymous

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

 

event triggers.png

 

If that doesn't work, there are other ways.

 

Cameron Whetten
Inventor 2014

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

Message 8 of 9
Anonymous
in reply to: cwhetten

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


Message 9 of 9
cwhetten
in reply to: Anonymous

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.  Smiley Happy

 

Cameron Whetten
Inventor 2014

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

Post to forums  

Autodesk Design & Make Report