Inventor General Discussion

Inventor General Discussion

Reply
Contributor
toon
Posts: 25
Registered: ‎08-13-2010
Message 1 of 9 (515 Views)
Accepted Solution

Change BOM Structure with iLogic

515 Views, 8 Replies
01-08-2014 06:08 AM

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.

Autodesk Product Design Suite Premium 2014
Windows 8.1
Spacepilot
*Expert Elite*
-niels-
Posts: 1,520
Registered: ‎06-20-2006
Message 2 of 9 (505 Views)

Re: Change BOM Structure with iLogic

01-08-2014 06:36 AM in reply to: toon
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...

Using IV2014 Pro SP2 - upd.1, Win7-64bit
Contributor
toon
Posts: 25
Registered: ‎08-13-2010
Message 3 of 9 (497 Views)

Re: Change BOM Structure with iLogic

01-08-2014 06:51 AM in reply to: -niels-
I get an error when I try that:
(translated: Bom for type PartCompenentDefinition not found)
Autodesk Product Design Suite Premium 2014
Windows 8.1
Spacepilot
*Expert Elite*
-niels-
Posts: 1,520
Registered: ‎06-20-2006
Message 4 of 9 (489 Views)

Re: Change BOM Structure with iLogic

01-08-2014 07:02 AM in reply to: toon

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.


Using IV2014 Pro SP2 - upd.1, Win7-64bit
*Expert Elite*
cwhetten
Posts: 1,072
Registered: ‎09-03-2008
Message 5 of 9 (475 Views)

Re: Change BOM Structure with iLogic

01-08-2014 09:50 AM in reply to: toon

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

Contributor
toon
Posts: 25
Registered: ‎08-13-2010
Message 6 of 9 (460 Views)

Re: Change BOM Structure with iLogic

01-08-2014 10:12 PM 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
Autodesk Product Design Suite Premium 2014
Windows 8.1
Spacepilot
*Expert Elite*
cwhetten
Posts: 1,072
Registered: ‎09-03-2008
Message 7 of 9 (440 Views)

Re: Change BOM Structure with iLogic

01-09-2014 10:34 AM in reply to: toon

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.

Contributor
toon
Posts: 25
Registered: ‎08-13-2010
Message 8 of 9 (423 Views)

Re: Change BOM Structure with iLogic

01-10-2014 01:48 AM 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


Autodesk Product Design Suite Premium 2014
Windows 8.1
Spacepilot
*Expert Elite*
cwhetten
Posts: 1,072
Registered: ‎09-03-2008
Message 9 of 9 (404 Views)

Re: Change BOM Structure with iLogic

01-10-2014 10:19 AM in reply to: toon

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.  :smileyhappy:

 

Cameron Whetten
Inventor 2014

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 or visit the Installation and Licensing Forum to get help installing your software.