iLogic exporting BoM including top assembly

iLogic exporting BoM including top assembly

Daniel_Stach94
Contributor Contributor
272 Views
3 Replies
Message 1 of 4

iLogic exporting BoM including top assembly

Daniel_Stach94
Contributor
Contributor

Hello,

I am trying to make an iLogic rule that exports BoM to excel including iProperties from the exported assembly ideally on the first row. I have already found and edited some rules so I am able to export the BoM according to my template, so even the old assemblies get right column order and then I sort it with custom iProperty. How do I add the same iProperties from assembly to the first row of BoM? 

 

'-----------------------------------------------------------------------------------------------------
'Check if assembly is active
oDoc = ThisDoc.ModelDocument
If oDoc.DocumentType = kPartDocumentObject Then
	MessageBox.Show("Pro export kusovníku musí být aktivní Sestava!", "Export kusovníku")
	Return
End If
'-----------------------------------------------------------------------------------------------------
oDoc = ThisApplication.ActiveDocument
Dim oBOM As BOM
oBOM = oDoc.ComponentDefinition.BOM
'-----------------------------------------------------------------------------------------------------
'Import BoM template
Dim oPath As String
oPath = "D:\Projekty\Tryskací zařízení\0KonecVaultu\Sablona_kusovniku_KS.xml"
oBOM.ImportBOMCustomization(oPath)
'-----------------------------------------------------------------------------------------------------
'Renumber BoM
Dim activeAssembly As AssemblyDocument = ThisApplication.ActiveDocument
Dim bomView As BOMView = activeAssembly.ComponentDefinition.BOM.BOMViews(2)
Call BOMView.Sort("He_HeOnum", True)
Call BOMView.Renumber(1, 1)

'Path for export
CSVpath = ThisDoc.Path + "\"

'the structured view to 'all levels'
	oBOM.StructuredViewFirstLevelOnly = False
'Make sure that the structured view is enabled.
	oBOM.StructuredViewEnabled = True
	Dim oStructuredBOMView As BOMView
	oStructuredBOMView = oBOM.BOMViews.Item("Strukturované")
'Export the BOM view to an Excel file
	oStructuredBOMView.Export(CSVpath + ThisDoc.FileName(False) + ".xls", kMicrosoftExcelFormat)

	i = MessageBox.Show("Přejete si zobrazit náhled kusovníku?", "Náhled kusovníku", MessageBoxButtons.YesNo)
	If i = vbYes Then : launchviewer = 1 : Else : launchviewer = 0 : End If 
	If launchviewer = 1 Then ThisDoc.Launch(CSVpath + ThisDoc.FileName(False) + ".xls")

 

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

A.Acheson
Mentor
Mentor

Here is a post to export the bom and sort and or delete columns based on exported bom xml  of the assembly.Ensure you export column headers as xml file and save in a location where this will be used later by 

 

oBOM.ImportBOMCustomization(BOMCustomizationFile)

 

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

Daniel_Stach94
Contributor
Contributor

Hi and thank you for your fast reply.
although I think this is not what I meant. I already have functioning rule for exporting BoM with a template for specific columns. Here is a picture of two BoMs.

Daniel_Stach94_0-1669880286958.png

The one of the left is exported BoM with my rule. The one on the right is how I would like to export the BoM. The exported assembly is 402-30000 and I need it on the first row. All the parts and sub-assemblies are then positioned below.

0 Likes
Message 4 of 4

A.Acheson
Mentor
Mentor

For this you will need the assembly document and retrieve its iproperties.

Dim PNo as String = oDoc.PropertySets.Item(“Design Tracking Properties”).Item(“Part Number”).Value
’Add to newly exported excel workbook and reposition afterwards.

In the export method your using you will need to move this value after in excel then reset the item/position. If you have 2023 there is options in bom export to position the bom results first then you could target directly the row to insert assembly data.

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