Inventor Vb.Net "AddIn" - Export BOM to Text File

Inventor Vb.Net "AddIn" - Export BOM to Text File

isocam
Collaborator Collaborator
558 Views
4 Replies
Message 1 of 5

Inventor Vb.Net "AddIn" - Export BOM to Text File

isocam
Collaborator
Collaborator

Can anybody help?

 

Does anybody have a Inventor Vb.Net "AddIn" source code that they could share to allow me to export a BOM to a text file that can be opened using "Notepad"?

 

Many thanks in advance!

 

Darren

0 Likes
559 Views
4 Replies
Replies (4)
Message 2 of 5

JelteDeJong
Mentor
Mentor

You could start by creating an (external) iLogic rule and then turning that rule into an addin. The iLogic rule could look something like this:

Dim dialog As Inventor.FileDialog
ThisApplication.CreateFileDialog(dialog)

dialog.Filter = "text *.csv|*.csv"
dialog.ShowSave()

Dim doc As AssemblyDocument = ThisDoc.Document

Dim bom As BOM = doc.ComponentDefinition.BOM
bom.StructuredViewEnabled = True
bom.StructuredViewFirstLevelOnly = False

Dim structuredView As BOMView = bom.BOMViews.Item("Structured")

structuredView.Export(dialog.FileName, FileFormatEnum.kTextFileCommaDelimitedFormat)

(This is the most basic rule I could think of but there are much more possibilities.)

Turning an iLogic rule into an addin is not that difficult. I have written a tutorial about it. you can find it here:

(Your question is about creating an addin but if you have a rule you can also use the addin Button Constructor to create a button for your rule without creating a complete addon.)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 5

Maxim-CADman77
Advisor
Advisor

... a bit off-topic, yet ...

 

@JelteDeJong 
Can you, please, explain why Button-Constructor Add-in (you call it "addin" which I believe is true) is named "Plug-in" at installer's greeting page title:

Button-Constructor_Installer_Greeting-Page - Copy.png

I wonder why all (in fact I tried only about ten) Add-ins at Autodesk App Store have that same ?wrong? installer title? 

Do all Add-in developers forced to use some particular You-Must-Use msi template (which one)?

 

Context:
I'm asking because I want to place my add-in to Autodesk App Store but just don't know where to start from.

Please vote for Inventor-Idea Text Search within Option Names

Message 4 of 5

bradeneuropeArthur
Mentor
Mentor

Or use it this way.

fully independent of the BOM selves.

Public Sub Main
Dim a As Inventor.AssemblyDocument = ThisDoc.Document
Dim b As Inventor.BOM = a.ComponentDefinition.BOM
Dim d As Inventor.Document = b.BOMViews.Item(1).BOMRows.Item(1).ComponentDefinitions.Item(1).Document'.ReferencedFileDescriptor.FullFileName
'b.BOMViews.Item(2).Sort2("item",True)
Dim b1 As Inventor.BOMRowsEnumerator = b.BOMViews.Item(2).BOMRows
b.BOMViews.Item(2).Sort("Item",True)

Dim oWrite  As System.IO.StreamWriter
oWrite = System.IO.File.CreateText(ThisDoc.PathAndFileName(False)& " Parts Only " &Today.Year & Today.Month & Today.Day & ".csv")
oWrite.WriteLine("Item" & ";" & "Part Number" & ";" & "Qty" & ";" & "Description"  & ";" & "BE_Description" & ";" & "Length" & ";" & "Flat Pattern Area" & ";" & "Flat Pattern Length" & ";" & "Flat Pattern Width" & ";"  & "Flat Pattern Thickness" & ";"  & "Be_Weight")


rcbom(b1,owrite)
'Dim x As String = Replace(d1.PropertySets.Item("Design Tracking Properties").Item("Flat Pattern Area").Value,".",",")
oWrite.Close
'GoExcel.Open(ThisDoc.PathAndFileName(False)& " Parts Only " &Today.Year & Today.Month & Today.Day & ".csv")
'Dim x As Microsoft.Office.Interop.Excel.ApplicationClass = New  Microsoft.Office.Interop.Excel.ApplicationClass
 ThisDoc.Launch(ThisDoc.PathAndFileName(False) & " Parts Only " & Today.Year & Today.Month & Today.Day & ".csv")

'w.SaveAs (ThisDoc.Launch(ThisDoc.PathAndFileName(False) & " Parts Only " & Today.Year & Today.Month & Today.Day & ".xlsx"))
'Dim w As Microsoft.Office.Interop.Excel.Workbook = x.Workbooks.Open(ThisDoc.PathAndFileName(False) & " Parts Only " & Today.Year & Today.Month & Today.Day & ".csv",,,,,,,," ; ",,,,,,)
'x.Visible = True

End Sub


Public Sub rcbom( b As Inventor.BOMRowsEnumerator, oWrite As System.IO.StreamWriter)
	For Each b1 As Inventor.BOMRow In b
	Dim d1 As Inventor.Document = b1.ComponentDefinitions.Item(1).Document
	
	Try
		
		oWrite.WriteLine(b1.ItemNumber & " ; " _
		& d1.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value _
		& " ; " & b1.TotalQuantity _
		& " ; " & d1.PropertySets.Item("Design Tracking Properties").Item("Description").Value _
		& " ; " & d1.PropertySets.Item("User Defined Properties").Item("Be_Description").Value _
		& " ; " & d1.PropertySets.Item("User Defined Properties").Item("Length").Value _
		& " ; " & replace(d1.PropertySets.Item("Design Tracking Properties").Item("Flat Pattern Area").Value,".",",") _
		& " ; " & Replace(d1.PropertySets.Item("Design Tracking Properties").Item("Flat Pattern Length").Value,".",",") _
		& " ; " & Replace(d1.PropertySets.Item("Design Tracking Properties").Item("Flat Pattern Width").Value,".",",") _
		& " ; " & Replace(d1.PropertySets.Item("User Defined Properties").Item("Mfp_Thickness").Value,".",",") _
		& " ; " & Replace(d1.ComponentDefinition.MassProperties.Mass, ".", ",") _
		& " ;" & "")
		'& ";" & (d1.PropertySets.Item("User Defined Properties").Item("Be_Weight").Value.ToString/ 1000) )
		Catch
			oWrite.WriteLine(b1.ItemNumber)
			End Try
	
	
	Try
		Dim b2 As Inventor.BOMRowsEnumerator = b1.ChildRows
			'MsgBox ("CH")
		rcbom(b2,oWrite)
		'Next
		Catch 
			End Try
	
	
	
	Next
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 5

JelteDeJong
Mentor
Mentor

I don't see much of a difference between plugins and addins so I never noticed it. Anyway, I did not create the installer. when you upload your addin then Autodesk will do that for you.

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com