Inventor Customization

Reply
Mentor
Lance_White
Posts: 154
Registered: ‎06-13-2011
Message 1 of 7 (1,543 Views)
Accepted Solution

Recurssive BOM

1543 Views, 6 Replies
06-19-2012 12:58 PM

I am trying to export a BOM form an assembly and there are sub-assemblies in the bom. I would like to export the BOM from those sub-assemblies also is there a way to do that?

 

What I am trying to do is create work orders so for instance; 711-100 has the part 810-100 as well as the assembly 800-100 in it.

 

I would an exported BOM to list every thing that is in 711-100 (I can do this) and also list the BOM from 800-100.

 

I would appreciate any nudges or hints it there is a way.


Lance W.
Inventor Pro 2013 (PDS Ultimate)
Vault Pro 2013
Windows 7 64
Xeon 2.4 Ghz 12GB

Hi Lance_White, 

 

Here is a sample iLogic rule that gets all levels of the BOM.  It might not be exactly what you're after, but should get you started.

 

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


 

' a reference to the assembly document.
' This assumes an assembly document is active.
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
'set a reference to the BOM
Dim oBOM As BOM
oBOM = oDoc.ComponentDefinition.BOM
'set the structured view to 'all levels'
oBOM.StructuredViewFirstLevelOnly = False
' Make sure that the structured view is enabled.
oBOM.StructuredViewEnabled = True
'set a reference to the "Structured" BOMView
Dim oStructuredBOMView As BOMView
oStructuredBOMView = oBOM.BOMViews.Item("Structured")
' Export the BOM view to an Excel file
oStructuredBOMView.Export ("C:\temp\BOM-StructuredAllLevels.xls", kMicrosoftExcelFormat)
'define Excel Application object
excelApp = CreateObject("Excel.Application")
'set Excel to run visibly
'change to false if you want to run it invisibly
excelApp.Visible = True

'open the workbook wb = excelApp.Workbooks.Open("C:\temp\BOM-StructuredAllLevels.xls")
'set all of the columns to autofit
excelApp.Columns.AutoFit 'suppress prompts (such as the compatibility checker) excelApp.DisplayAlerts = false 'save the workbook wb.Save ''close the workbook, uncomment if you want to close the xls file at the end ''wb.Close

 

*Expert Elite*
Curtis_Waguespack
Posts: 2,930
Registered: ‎03-08-2006
Message 2 of 7 (1,540 Views)

Re: Recurssive BOM

06-19-2012 01:17 PM in reply to: Lance_White

Hi Lance_White, 

 

Here is a sample iLogic rule that gets all levels of the BOM.  It might not be exactly what you're after, but should get you started.

 

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


 

' a reference to the assembly document.
' This assumes an assembly document is active.
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument

'set  a reference to the BOM
Dim oBOM As BOM
oBOM = oDoc.ComponentDefinition.BOM

'set the structured view to 'all levels'
oBOM.StructuredViewFirstLevelOnly = False

' Make sure that the structured view is enabled.
oBOM.StructuredViewEnabled = True

'set a reference to the "Structured" BOMView
Dim oStructuredBOMView As BOMView
oStructuredBOMView = oBOM.BOMViews.Item("Structured")

' Export the BOM view to an Excel file
oStructuredBOMView.Export ("C:\temp\BOM-StructuredAllLevels.xls", kMicrosoftExcelFormat)

'define Excel Application object
excelApp = CreateObject("Excel.Application")
'set Excel to run visibly
'change to false if you want to run it invisibly
excelApp.Visible = True

'open the workbook wb = excelApp.Workbooks.Open("C:\temp\BOM-StructuredAllLevels.xls")
'set all of the columns to autofit
excelApp.Columns.AutoFit 'suppress prompts (such as the compatibility checker) excelApp.DisplayAlerts = false 'save the workbook wb.Save ''close the workbook, uncomment if you want to close the xls file at the end ''wb.Close

 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Mentor
Lance_White
Posts: 154
Registered: ‎06-13-2011
Message 3 of 7 (1,509 Views)

Re: Recurssive BOM

06-20-2012 05:23 AM in reply to: Curtis_Waguespack

Thanks alot.

 

Really like your blog by the way, its been a huge help with learning iLogic.


Lance W.
Inventor Pro 2013 (PDS Ultimate)
Vault Pro 2013
Windows 7 64
Xeon 2.4 Ghz 12GB
Valued Contributor
nandakumar.hegde
Posts: 56
Registered: ‎05-25-2005
Message 4 of 7 (1,253 Views)

Re: Recurssive BOM

01-03-2013 09:39 AM in reply to: Curtis_Waguespack

hi,

it is a good code.But I want to export all part regardless of reference part os sub assembly. it doesn't export "Reference" assembly/ parts.

 

Kindly advice. I am not a progarmmer. Please add updated code.

 

regards,

nanda

Inventor 2011

*Expert Elite*
Curtis_Waguespack
Posts: 2,930
Registered: ‎03-08-2006
Message 5 of 7 (1,245 Views)

Re: Recurssive BOM

01-03-2013 10:58 AM in reply to: nandakumar.hegde

Hi nandakumar.hegde,

 

Here is an updated example that sets the BOM structure of the occurence and the actual file not to be Reference before exporting the BOM.

 

I see that you have posted to several other existing threads asking the same question. You might want to remove those posts, or reply to them and point future readers to this example (assuming that it provides a solution.)

 

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

 

' a reference to the assembly document.
' This assumes an assembly document is active.
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument

oCompDef = oDoc.ComponentDefinition
Dim oCompOcc As ComponentOccurrence
	'Find all occurrences
	For Each oCompOcc In oCompDef.Occurrences
	'if component BOM structure is reference then change it to default
	If oCompOcc.BOMStructure = BOMStructureEnum.kReferenceBOMStructure Then
	'set the occurence not to be Reference
	oCompOcc.BOMStructure =  BOMStructureEnum.kDefaultBOMStructure
	'set the file not to be Reference
	oCompOcc.Definition.BOMStructure =  BOMStructureEnum.kNormalBOMStructure
	End If
	Next
	
'set  a reference to the BOM
Dim oBOM As BOM
oBOM = oDoc.ComponentDefinition.BOM

'set the structured view to 'all levels'
oBOM.StructuredViewFirstLevelOnly = False

' Make sure that the structured view is enabled.
oBOM.StructuredViewEnabled = True

'set a reference to the "Structured" BOMView
Dim oStructuredBOMView As BOMView
oStructuredBOMView = oBOM.BOMViews.Item("Structured")

' Export the BOM view to an Excel file
oStructuredBOMView.Export ("C:\temp\BOM-StructuredAllLevels.xls", kMicrosoftExcelFormat)

'define Excel Application object
excelApp = CreateObject("Excel.Application")
'set Excel to run visibly
'change to false if you want to run it invisibly
excelApp.Visible = True

'open the workbook
wb = excelApp.Workbooks.Open("C:\temp\BOM-StructuredAllLevels.xls")
'set all of the columns to autofit
excelApp.Columns.AutoFit
'suppress prompts (such as the compatibility checker)
excelApp.DisplayAlerts = false
'save the workbook
wb.Save

''close the workbook, uncomment if you want to close the xls file at the end
''wb.Close

 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





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

Re: Recurssive BOM

01-03-2013 11:10 AM in reply to: Curtis_Waguespack

hello Curtis,

My idea is to export all parts to excel regardless of BOM structure. I tried your code still it doesn't export the reference part to excel. Please find the screen shot.

I tryied Inventor BOM export which does the same. My assembly contain about 10000 part. but excel shows only 8000 parts.

 

thanks for your suport.

Valued Mentor
saseendrankombath
Posts: 357
Registered: ‎11-11-2005
Message 7 of 7 (1,225 Views)

Re: Recurssive BOM

01-04-2013 02:34 AM in reply to: nandakumar.hegde

Try parts only BOM View insed of Structured BOM View

oBOM.PartsOnlyViewEnabled = True
oBomview = oBOM.BOMViews.Item("Parts Only")

 

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.