Custom BOM style output EXECL

Custom BOM style output EXECL

nivyus
Contributor Contributor
442 Views
3 Replies
Message 1 of 4

Custom BOM style output EXECL

nivyus
Contributor
Contributor

Due to the needs of the project, this is the BOM style I set myself and directly output EXECL format. How to write code, thank you very much. Or output EXECL according to the BOM style currently being extracted from the engineering drawings.

 

BOM样式.jpg

BOM样式1.jpgBOM样式2.jpgBOM样式3.jpg

0 Likes
443 Views
3 Replies
Replies (3)
Message 2 of 4

Ralf_Krieg
Advisor
Advisor

Hello

 

I'm not 100% clear what you want to achive. You say BOM and your picture shows partslists. You want to set the partsliststyle of the partslist on the active sheet in a drawing to a named style and export afterwards?

Try:

Private Sub ChangePartsLisStyle()

Dim sPLSName As String
Dim sFileName As String
sPLSName = "MyPartsListStyleName" '<-------------Change this !!!
sFileName = "MyFullPathAndExcelFileName" '<-------------Change this !!!

Dim oDoc As DrawingDocument
Set oDoc = ThisApplication.ActiveDocument

Dim oSheet As Sheet
Set oSheet = oDoc.ActiveSheet

Dim oPL As PartsList
Set oPL = oSheet.PartsLists(1)

Dim oPLS As PartsListStyle
For Each oPLS In oDoc.StylesManager.PartsListStyles
    If oPLS.Name = oPLSName Then
        oPL.Style = oPLS
        oSheet.Update
        
        Call oPL.Export(sFileName, kMicrosoftExcel)
    End If
Next

End Sub

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
0 Likes
Message 3 of 4

nivyus
Contributor
Contributor

I need to select the corresponding style from the parts list style of the drawing to export EXECL。

Different parts have different requirements and bring out different data. There are multiple parts list styles。

Can you help improve it, thank you!

0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor

Hi @nivyus.  Do you mean like this (see code below)?  This gets the list of PartsListStyle names, then shows that to you so you can select the one you want, then applies the chosen style to the parts list.  This is just a simple example to show you how to do that, if that is what you wanted.  I also included some commented out lines of code for exporting the parts list to Excel, but those settings would likely all have to be changed to suit your needs.

 

oDDoc = ThisDrawing.Document
oSheet = oDDoc.ActiveSheet
If oSheet.PartsLists.Count = 0 Then Exit Sub
Dim oPList As PartsList = oSheet.PartsLists.Item(1)
oPListStyles = oDDoc.StylesManager.PartsListStyles
Dim oPListStyleNames As New List(Of String)
For Each oPLStyle As PartsListStyle In oPListStyles
	oPListStyleNames.Add(oPLStyle.Name)
Next
oPLStyleName = InputListBox("Choose PartsList Style.", oPListStyleNames, oPListStyleNames.Item(1), "PartsList Styles")
If String.IsNullOrEmpty(oPLStyleName) Then Exit Sub
oStyle = oPListStyles.Item(oPLStyleName)
oPList.Style = oStyle

'oOptions = ThisApplication.TransientObjects.CreateNameValueMap
'oOptions.Add("TableName", oPList.Title)
''oOptions.Add("ExportedColumns", "ColumnTitle1 ; ColumnTitle2")
'oOptions.Add("IncludeTitle", True)
'oOptions.Add("StartingCell", "A1")
'oOptions.Add("Template", "C:\Temp\PartsList Export Template.xls")
'oOptions.Add("AutoFitColumnWidth", True)
'oPList.Export("C:\Temp\PartsList 1.xls", PartsListFileFormatEnum.kMicrosoftExcel, oOptions)

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡 or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes