Message 1 of 3
BOM Export to Template including Instance Properties
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
with the help of a nice Tutorial and Forum posts I've been able to Export the BOM to an excel Template at a defined row.
Now I also want to use the new Instance Properties, where we want to overwrite some Custom Iproperties (expecially because of Content Center files).
Is there any way to read out if an Custom Iproperty has been overwritten by an Instance Property? Then this Instance Property should be used instead of the Custom IProp.
Thanks in Advance!
In the following you can find the Ilogic Code:
Sub Main() Dim oAssydoc As AssemblyDocument oAssydoc = ThisApplication.ActiveDocument Dim oAssyCompDef As AssemblyComponentDefinition oAssyCompDef = oAssydoc.ComponentDefinition Dim oBOM As BOM oBOM = oAssyCompDef.BOM Dim oBOMView As BOMView 'BOM View "Strukturiert"(GERMAN) = "Structured) oBOMView = oBOM.BOMViews.Item("Strukturiert") oBOM.StructuredViewEnabled = True oBOM.StructuredViewFirstLevelOnly = True 'BOM Export 'Copy Job Information Spreadsheet from workspace Dim sJobBOMTempName As String = String.Concat("D:\Template-BOM.xlsx") Dim sJobBOMName As String = String.Concat("D:\BOM.xlsx") IO.File.Copy(sJobBOMTempName, sJobBOMName, True) Dim sMySheet As String = "BOM" Static iCurrRow As Integer = 9 GoExcel.Open(sJobBOMName, sMySheet) 'Write BOM values to Excel Call QueryBOMRowProperties(oBOMView.BOMRows, sJobBOMName, iCurrRow) oAssydoc.Save 'Save Excel GoExcel.Save GoExcel.Close End Sub Public Sub QueryBOMRowProperties(oBOMRows As BOMRowsEnumerator, JobSpreadsheetName As String, iCurrRow As Integer) ' Iterate through the contents of the BOM Rows. Static CurrentRow As Integer = iCurrRow Dim i As Long Dim sWriteCell As String For i = 1 To oBOMRows.Count 'Get the current row Dim oRow As BOMRow oRow = oBOMRows.Item(i) 'Set a referance to the primary ComponentDefinition of the row Dim oCompDef As ComponentDefinition oCompDef = oRow.ComponentDefinitions.Item(1) Dim oPropSets As PropertySets oPropSets = oCompDef.Document.PropertySets oDesignTrackingPropertySet = oPropSets.Item("Design Tracking Properties") oInventorSummaryPropertySet = oPropSets.Item("Inventor Summary Information") oInventorDocSummaryPropertySet = oPropSets.Item("Inventor Document Summary Information") oCustomPropertySet = oPropSets.Item("Inventor User Defined Properties") 'Get the file properties that are required oItemNumberProperty = oRow.ItemNumber oDescriptionProperty = oDesignTrackingPropertySet.Item("Description") sWriteCell = "A" & CurrentRow GoExcel.CellValue(sWriteCell.AsEnumerable) = oItemNumberProperty sWriteCell = "B" & CurrentRow GoExcel.CellValue(sWriteCell.AsEnumerable) = oRow.ItemQuantity sWriteCell = "C" & CurrentRow GoExcel.CellValue(sWriteCell) = oDescriptionProperty.Value 'Write Custom Ipropterties to Excel "Werkstoffnorm" 'HOW To Write INSTANCE PROPERTIES To EXCEL, WHERE SOME OF THESE CUSTOM iProperties HAVE BEEN OVERWRITTEN? Try oMatNormProperty = oCustomPropertySet.Item("Werkstoffnorm") sWriteCell = "E" & CurrentRow GoExcel.CellValue(sWriteCell) = oMatNormProperty.Value Catch End Try Try oBeschProperty = oCustomPropertySet.Item("Bescheinigung") sWriteCell = "F" & CurrentRow GoExcel.CellValue(sWriteCell) = oBeschProperty.Value Catch End Try CurrentRow = CurrentRow + 1 'Recursively iterate child rows if present. If Not oRow.ChildRows Is Nothing Then Call QueryBOMRowProperties(oRow.ChildRows, JobSpreadsheetName, CurrentRow) Else End If Next i End Sub