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 Default BOM Structure in Multiple Parts/Assemblies

13 REPLIES 13
SOLVED
Reply
Message 1 of 14
phlyx
1784 Views, 13 Replies

Change Default BOM Structure in Multiple Parts/Assemblies

We are in process of migrating a recently acquired from SolidWorks into Inventor.  We found we can open the SW files directly with Inventor 2020 and although they come in as un-constrained somewhat dumb solids it is very helpful.   We have also found things like Recognize Features helps add some intelligence when needed.  The thing we're finding is every assembly and parts in the assemblies we open come in as Default BOM Structure "Purchased".  

 

Not sure if there is something we can do to change what BOM structure they come in as.  Would be very interested in finding a way to change the BOM structure in multiple parts/assemblies quickly.  Any hints or suggestions?

13 REPLIES 13
Message 2 of 14
Mark.Lancaster
in reply to: phlyx

@phlyx 

 

Unless I'm missing something why can't you just change it through the assembly BOM

 

2020-01-20_17-22-34.jpg

 

Then you could sort by that column and change as needed.

 

Or are you looking for more of an automated way?

Mark Lancaster


  &  Autodesk Services MarketPlace Provider


Autodesk Inventor Certified Professional & not an Autodesk Employee


Likes is much appreciated if the information I have shared is helpful to you and/or others


Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

Message 3 of 14
phlyx
in reply to: Mark.Lancaster

We have two major machine assemblies and each has dozens of sub-assemblies and over 1,000 parts in each.  All the assemblies and all the parts in them has the BOM set to "Purchased" and needs to be set to "Normal".  Could change it in the BOM of the sub-assemblies and the top level assembly if we had a spare few weeks but looking for a way to do something like select all the parts in an assembly and set them to Normal in one swing of the magic staff of BOM properties  💥

Message 4 of 14
johnsonshiue
in reply to: phlyx

Hi! I think you will need to do that in individual files. One can write a script to set Tools -> Doc Setting -> BOM. You will need to do it for all affected parts.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 5 of 14
GeorgK
in reply to: phlyx

' set a reference to the assembly component definintion
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
  'set BOM Structure
  oOccurrence.Definition.BOMStructure = 51970 'Normal
Next

'kDefaultBOMStructure=51969 'The Default Structure type.
'kInseparableBOMStructure=51974 'The inseparable Structure type.
'kNormalBOMStructure=51970 'The normal Structure type.
'kPhantomBOMStructure=51971 'The phantom Structure type.
'kPurchasedBOMStructure=51973  ' The purchased Structure type.
'kReferenceBOMStructure=51972 'The reference Structure type.
'kVariesBOMStructure=51975 'The Structure type varies amongst references.

@phlyx  You can use this iLogic code to update the bom.

Message 6 of 14
phlyx
in reply to: GeorgK

WOW!!!  That's awesome!  Mega kudos to  GeorgK  👍

Message 7 of 14
phlyx
in reply to: GeorgK

Oh course within a little bit of celebrating the solution I stub my toe.  I am not finding some sub-assemblies that are half purchased parts and half machined (normal) parts.  So if I use this iLogic one way or another I end up manually changing the BOM status of half the parts.  Don't want to overstep my bounds or impose, but is there any way to make this so it only changes the BOM property for selected items (parts and/or assemblies)?

Message 8 of 14
GeorgK
in reply to: phlyx

You can combine the code with this one:

 

Sub Main()
'Make a ref to active doc
Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument

'selected components collection
Dim oSelected As ObjectCollection
oSelected = ThisApplication.TransientObjects.CreateObjectCollection

Dim oCount As Integer
oCount = oDoc.SelectSet.Count

'Check that at least 1 is selected
If oCount = 0 Then
	'MessageBox.Show("Please select a component.", "iLogic")
	Exit Sub 'bail out
End If

'add to Object Collection
Dim i As Long
For i = 1 To oCount
	If oDoc.SelectSet.Item(i).Type = _
		ObjectTypeEnum.kComponentOccurrenceObject Then
		oSelected.Add (oDoc.selectSet.Item(i))
	End If
Next

'do stuff to the selected files here:

'get names item name from collection
For Each oItem in oSelected
	oMsg = oMsg & vbLf & oItem.Name
Next

MessageBox.Show(oCount _
& " Component(s) selected." & vbLf & oMsg, "iLogic")

End Sub
Message 9 of 14
phlyx
in reply to: GeorgK

Wow, thanks and very much appreciate the help.  And please excuse my iLogic ignorance but how do you "combine" the two routines?  🙄

Message 10 of 14
phlyx
in reply to: phlyx

Any help on "combining" the 2 iLogic rules?????  😬

Message 11 of 14
Curtis_Waguespack
in reply to: phlyx

Hi @phlyx ,

 

here are a couple quick versions (note I didn't really test them, but hopefully not errors)

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

here is a version of the first rule that only changes parts that currently set as "Purchased" to be Normal

' set a reference to the assembly component definintion
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences
  	'set BOM Structure
  	If oOccurrence.Definition.BOMStructure = BOMStructureEnum.kPurchasedBOMStructure Then
  	oOccurrence.Definition.BOMStructure = BOMStructureEnum.kNormalBOMStructure
	End If
Next

 

here are the combined rules which sets all selected occurrences to be Normal

Sub Main()
'Make a ref to active doc
Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument

'selected components collection
Dim oSelected As ObjectCollection
oSelected = ThisApplication.TransientObjects.CreateObjectCollection

Dim oCount As Integer
oCount = oDoc.SelectSet.Count

'Check that at least 1 is selected
If oCount = 0 Then
	MessageBox.Show("Please select a component.", "iLogic")
	Exit Sub 'bail out
End If

'add to Object Collection
Dim i As Long
For i = 1 To oCount
	If oDoc.SelectSet.Item(i).Type = _
		ObjectTypeEnum.kComponentOccurrenceObject Then
		oSelected.Add (oDoc.SelectSet.Item(i))
	End If
Next



'get names item name from collection
For Each oItem In oSelected

	' set a reference to the assembly component definintion
	Dim oAsmCompDef As AssemblyComponentDefinition
	oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

	'Iterate through all of the occurrences
	Dim oOccurrence As ComponentOccurrence
	For Each oOccurrence In oAsmCompDef.Occurrences
	  	'set BOM Structure
	  	If oItem.Name = oOccurrence.Name Then
	  	oOccurrence.Definition.BOMStructure = BOMStructureEnum.kNormalBOMStructure
  		End If
	Next
Next
End Sub

Message 12 of 14
phlyx
in reply to: Curtis_Waguespack

Copied and pasted wrong but figured out what I did.  That second part was perfect.  Also found we can change that final part to BOMStructureEnum.kPurchasedBOMStructure and change selected items to Purchased so we can make a rule for each type we want selected items to be changed to.  

 

THANK YOU!!!!!!!!!!!!!!!!!!

Message 13 of 14

I've copied the code and swapped out Normal with purchased. Then I get the "Please select a component" message. Where do I select the components?

 

My goal here is to apply the Purchased BOM structure to absolutely everything in the path C:\VaultWS\Purchased Parts\[113 subfolders with their respective parts and assemblies] preferably without having to open any of them. I just want to batch apply this to an entire subfolder (with more sub folders) in my Vault project folder.

Message 14 of 14

This works! Thank you so much.

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

Post to forums  

Autodesk Design & Make Report