Selecting folder while exporting BOM

Selecting folder while exporting BOM

Anonymous
Not applicable
571 Views
3 Replies
Message 1 of 4

Selecting folder while exporting BOM

Anonymous
Not applicable

Hi,

I have a rule for exporting BOM from my assemblies, but want to be able to select the folder in which i can save the exported excel file.

Is there a way to add a pop up window to the rule, which will let me select save folder?

 

Rule i am using:

Dim oDoc As AssemblyDocument = ThisDoc.Document
Dim oBOM As BOM = oDoc.ComponentDefinition.BOM

oBOM.PartsOnlyViewEnabled=True

ThisBOM.Export("Parts Only", "C:\Temp\TestBOMExport.xls", FileFormatEnum.kMicrosoftExcelFormat)
0 Likes
Accepted solutions (1)
572 Views
3 Replies
Replies (3)
Message 2 of 4

m.rymut
Advocate
Advocate
Accepted solution

I have something like this: 

 

Imports System.Windows.Forms

Dim Dialog = New FolderBrowserDialog()
Dialog.SelectedPath = ExportPath
Dialog.ShowNewFolderButton = True
Dialog.Description = "Choose folder: "
If DialogResult.OK = Dialog.ShowDialog() Then
ExportPath = Dialog.SelectedPath & "\"
Else
Return
End If

FileName = ThisDoc.FileName(False)
BOMFile = ExportPath & FileName & ".xls"
ThisBOM.Export("Parts Only", BOMFile, kMicrosoftExcelFormat)

 

But i think someone more experienced could do it better, mine is just a mish mash of some codes i found online and my own

Message 3 of 4

A.Acheson
Mentor
Mentor
@m.rymut  That method looks good to open up inventor folder dialogue. It can be found as a sample in the API help also with location shown in this post.

Here is another method to pick the folder path that the assembly document is in this way you can avoid the timely folder dialogue if you save in the same location each time.

 

 

ThisDoc.Path

 

 

 And here is how to insert assembly document name as excel sheet name 

 

 

 ThisDoc.PathAndFileName(False) 

 

 

More info on working with document here

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 4 of 4

Anonymous
Not applicable
Thanks for reply, I wanted to have a folder dialogue every time when I export BOM, so that I could choose where to save every time.
0 Likes