Inventor 2018 Ilogic export BOM to Excel file

Inventor 2018 Ilogic export BOM to Excel file

Anonymous
Not applicable
1,389 Views
4 Replies
Message 1 of 5

Inventor 2018 Ilogic export BOM to Excel file

Anonymous
Not applicable

Dear,

I want to create a rule in an Inventor assembly drawing with a Parts list (BOM view - structured) with following functions:

- Create a new Excel file in the path of the project (no problem to find path)

- Export the BOM of the assembly drawing to this new Excel file

      -> this doesn't work I don't know how

- Pick a standard template to export this BOM and choose the starting cell. (As you can do manually - but how in iLogic?)

 

The export function doesn't seem to work with me...

 

Dim pathProject As String 
	Dim pathExcelFile As String
	Dim nameExcel As String
	Dim WO As String
	
	pathProject = ThisDoc.WorkspacePath()
	pathExcelFile = pathProject + "\Doc\"
	
	'WO are the number left of this seperator '-'
	Dim Separators() As Char = {"-"} 
	Sentence = iProperties.Value("Project", "Part Number")
	Words = Sentence.Split(Separators)
	WO = Words(0)
	Parameter.UpdateAfterChange = True
	iLogicVb.UpdateWhenDone = True

	nameExcel = WO + "-stuklijst.xls"
	
	'Filename van Excel aanmaken (openen of nieuw)
	myXLS_File = pathExcelFile + nameExcel
	
	oDoc = ThisDoc.ModelDocument
	If oDoc.DocumentType = kPartDocumentObject Then
		MessageBox.Show("You need to be in an Assembly to create BOM", "Noassembly")
	Return
	End If
	oDoc = ThisApplication.ActiveDocument
	Dim oBOM As BOM
'THIS LINE BELOW GIVES A DECLARATION FAULT.. HELP
	oBOM = oDoc.ComponentDefinition.BOM	
		
	'STRUCTURED BoM
	oBOM.StructuredViewFirstLevelOnly = False
	oBOM.StructuredViewEnabled = True
	Dim oStructuredBOMView As BOMView
'HERE ALSO A DECLARATION FAULT
	oStructuredBOMView = ThisBOM.BOMViews.Item("Structured")
	'Export BOM view naar Excel file
	oStructuredBOMView.Export(myXLS_File, kMicrosoftExcelFormat)

 

0 Likes
Accepted solutions (1)
1,390 Views
4 Replies
Replies (4)
Message 2 of 5

Sergio.D.Suárez
Mentor
Mentor

Hi, I ask why it has not been very clear to me. Are you working on a drawing file, and do you have a PartList and want to export this partList to excel? Because a PartList is not the same as a BOM. A BOM is in an assembly, your document must be an assembly, not a drawing file.


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

0 Likes
Message 3 of 5

Anonymous
Not applicable

I am working in a drawing file.

Step 1) I do manually: parts list of an assembly

Step 2) I change the structured BOM as I want it -> Parts list in drawing gets adapted

Step 3) What I used to do: Right mouse click on parts list in drawing to export the parts list to Excel.

I'd like to change step 3 by running a rule in a drawing (.idw). So it makes automatically a parts list in Excel.

 

But maybe this is not possible? Maybe I can only do this in the .iam file and not in the .idw file? And function ThisBom.Export works only in .iam files?

0 Likes
Message 4 of 5

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

I am not clear on what you have tried to do with the code. Here is a simple code. You have a drawing file with a model of an assembly in a view. If you activate this rule it will create a PartList of the model. You can specify by modifying the code the type of PartList. Then Export to Excel.
I hope it helps with your problem. regards

 

Dim oFileName As String = ThisDoc.Path & "\Export_PartList.xlsx"    ' Excel Filename
Dim oColumn As Integer = 4 ' Sort by column number = 4

Dim oDrawingDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheet As Sheet= oDrawingDoc.ActiveSheet
Dim oDrawingView As DrawingView= oSheet.DrawingViews(1)
Dim oBorder As Border= oSheet.Border
Dim oPlacementPoint As Point2d
xrev = oBorder.RangeBox.MaxPoint.X
yrev = oBorder.RangeBox.MaxPoint.Y
oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(xrev, yrev)
Dim oPartsList As PartsList
oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint, 46594)   'Add PartList
'kFirstLevelComponents 46593 First level components. 
'kPartsOnly 46594 Parts only. 
'kStructured 46593 Structured first level components. 
'kStructuredAllLevels 46595 Structured all components. 

oPartsList.Sort(oPartsList.PartsListColumns(oColumn).Title)  ' Sort by column number = 4
oPartsList.Renumber
oPartsList.Style.UpdateFromGlobal

oPartsList.Export(oFileName,48642)
'kdBASEIII 48643 dBASE III. 
'kdBASEIV 48644 dBASE IV. 
'kMicrosoftAccess 48641 Microsoft Access. 
'kMicrosoftExcel 48642 Microsoft Excel. 
'kTextFileCommaDelimited 48647 Text File Comma Delimited. 
'kTextFileTabDelimited 48646 Text File Tab Delimited. 
'kUnicodeTextFileCommaDelimited 48649 Unicode Text File Comma Delimited. 
'kUnicodeTextFileTabDelimited 48648 Unicode Text File Tab Delimited. 

 


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 5 of 5

kurt.rogers
Observer
Observer

@Sergio.D.Suárez  I`d like to use the code but to read an existing parts list already present on the drawing.

 

you code adding one is fantastic however I have 1000`s of drawings with parts lists already present 

 

Please can you help me with this?

0 Likes