Automatic BOM export

Automatic BOM export

Anonymous
Not applicable
772 Views
6 Replies
Message 1 of 7

Automatic BOM export

Anonymous
Not applicable

I want use iLogic to export my BOM. There is the build-in command:

 

ThisBOM.Export("Parts Only", "fileName", kMicrosoftExcelFormat  

 

But the problem is, every time I run that, it shuffles the columns into alphabetical order but I want it to be in the order that it set up as. When you go to Manage > Bill of Materials > Export, it exports it the way I want, but it doesn't do it properly when I run iLogic. I'm just looking for a way to automate this.

 

Thanks

Nick

0 Likes
773 Views
6 Replies
Replies (6)
Message 2 of 7

k14348
Advocate
Advocate

u need BOM from idw file or iam file?

-karthikeyan

0 Likes
Message 3 of 7

frederic.vandenplas
Collaborator
Collaborator

Hi,

 

I could reproduce the issue, with the API you can do more then with the basic ilogic function.

I just put a BomView.Sort on your item and then exported the bom

Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
'  a reference to the BOM
Dim oBOM As BOM = oDoc.ComponentDefinition.BOM
'  the structured view to 'all levels'
' Make sure that the parts only view is enabled.
oBOM.PartsOnlyViewEnabled = True
'  a reference to the "Parts Only" BOMView
Dim oPartsOnlyBOMView As BOMView = oBOM.BOMViews.Item("Parts Only")
' Sort the bom
oPartsOnlyBOMView.sort("Item",True) 'ColumnName','Ascending=True/Descending=False'
' Export the BOM view to an Excel file
oPartsOnlyBOMView.Export ("C:\temp\test.xls", kMicrosoftExcelFormat)
If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
Message 4 of 7

Anonymous
Not applicable

Preferably from the .iam

0 Likes
Message 5 of 7

Anonymous
Not applicable

This will sort the rows, but how can I sort the columns? Thanks for this bit though!

0 Likes
Message 6 of 7

frederic.vandenplas
Collaborator
Collaborator

Doh, i was looking at the export and found that the rows where not sorted neither.

Apparently the API call and the Export BOM built in function differ entirely and are not synchronised (google search)

 

So i would report this as a bug or as an improvement idea

 

As an alternative you can use excel COM to arrange the columns there.

If you think this answer fullfilled your needs, improved your knowledge or leads to a solution,
please feel free to "kudos"
0 Likes
Message 7 of 7

Anonymous
Not applicable

The weird part about that is that if you go through the BOM interface, you can export according to your current layout just fine. Is it possible to use an xml template of the BOM to export the current BOM through. Basically use the code you provided to apply the template.

0 Likes