Here is the part of code where the properties are extracted and then passed to a class
Public Sub QueryBOMRowProperties2(oBOMRows As BOMRowsEnumerator, sNotaSheet As Excel.Worksheet)
Dim ESBomRows As New List(Of EdSiBomRow)
FillBomRowsList(oBOMRows, ESBomRows)
WriteToExcel(ESBomRows, sNotaSheet)
End Sub
Private Sub FillBomRowsList(oBomRows As BOMRowsEnumerator, ESBomRows As List(Of EdSiBomRow))
For Each oRow As BOMRow In oBomRows
'Set a reference to the primary ComponentDefinition of the row
Dim oCompDef As ComponentDefinition
oCompDef = oRow.ComponentDefinitions.Item(1)
' Imposta iProperties
Dim oPropSets As PropertySets
oPropSets = oCompDef.Document.PropertySets
Dim oInventorSummaryPropertySet = oPropSets.Item("Inventor Summary Information") 'Riepilogo
Dim oInventorDocumentPropertySet = oPropSets.Item("Inventor Document Summary Information") ' Riepilogo Documento
Dim oDesignTrackingPropertySet = oPropSets.Item("Design Tracking Properties") ' Progetto
Dim oCustomPropertySet = oPropSets.Item("Inventor User Defined Properties") ' Personalizzate
'Get the file properties that are required
Dim ESBomRow = New EdilSiderBomRow()
Dim oType As Integer
' ----------Riepilogo----------
ESBomRow.iTitle = oInventorSummaryPropertySet.Item("Title").Value ' Iproperties Titolo
ESBomRow.iSubject = oInventorSummaryPropertySet.Item("Subject").Value ' iProperties Oggetto
ESBomRow.iAuthor = oInventorSummaryPropertySet.Item("Author").Value ' iProperties Autore
ESBomRow.iManager = oInventorDocumentPropertySet.Item("Manager").Value 'iProperties Responsabile
ESBomRow.iCompany = oInventorDocumentPropertySet.Item("Company").Value 'iProperties Società
ESBomRow.iCategory = oInventorDocumentPropertySet.Item("Category").Value 'iProperties Categoria
ESBomRow.iKeywords = oInventorSummaryPropertySet.Item("Keywords").Value 'iProperties Parola chiave
ESBomRow.iComments = oInventorSummaryPropertySet.Item("Comments").Value ' iProperties Commenti
' ----------Progetto----------
'Verifica se il componente è virtuale
If TypeOf oRow.ComponentDefinitions.Item(1) Is VirtualComponentDefinition Then
ESBomRow.iPartNumber = oRow.ComponentDefinitions.Item(1).PropertySets.Item("Design Tracking Properties").Item("Part Number").Value ' iProperties Numero Parte Componente Virtuale
ESBomRow.iStockNumber = oRow.ComponentDefinitions.Item(1).PropertySets.Item("Design Tracking Properties").Item("Stock Number").Value ' iProperties Numero di Magazzino Componente Virtuale
ESBomRow.iDescription = oRow.ComponentDefinitions.Item(1).PropertySets.Item("Design Tracking Properties").Item("Description").Value ' iProperties Descrizione Componente Virtuale
ESBomRow.iDocumentSubTypeName = oRow.ComponentDefinitions.Item(1).PropertySets.Item("Design Tracking Properties").Item("Document SubType Name").Value 'iProperties Nome Sottotipo
ESBomRow.iDocumentSubType = oRow.ComponentDefinitions.Item(1).PropertySets.Item("Design Tracking Properties").Item("Document SubType").Value 'iProperties Sottotipo
Dim virtualComp As VirtualComponentDefinition = CType(oRow.ComponentDefinitions.Item(1), VirtualComponentDefinition)
Debug.WriteLine("🔹 Componente Virtuale: " & virtualComp.DisplayName)
Try
' Elenca tutti i PropertySet disponibili
For Each propSet As PropertySet In virtualComp.PropertySets
Debug.WriteLine(" 📂 PropertySet: " & propSet.Name)
' Stampa tutte le proprietà disponibili in quel PropertySet
For Each prop As [Property] In propSet
Debug.WriteLine(" - " & prop.Name & " = " & prop.Value.ToString())
Next
Next
Catch ex As Exception
Debug.WriteLine(" ❌ Errore durante il recupero delle proprietà: " & ex.Message)
End Try
Debug.WriteLine("-------------------------------------------------")
Else
ESBomRow.iDocumentSubTypeName = oDesignTrackingPropertySet.Item("Document SubType Name").Value 'iProperties Nome Sottotipo
ESBomRow.iDocumentSubType = oDesignTrackingPropertySet.Item("Document SubType").Value 'iProperties Sottotipo
ESBomRow.iPartNumber = oDesignTrackingPropertySet.Item("Part Number").Value ' iProperties Numero Parte Componente Virtuale
ESBomRow.iStockNumber = oDesignTrackingPropertySet.Item("Stock Number").Value ' iProperties Numero di Magazzino Componente Virtuale
ESBomRow.iDescription = oDesignTrackingPropertySet.Item("Description").Value ' iProperties Descrizione Componente Virtuale
End If
ESBomRow.iRevisionNumber = oInventorSummaryPropertySet.Item("Revision Number").Value 'iProperties Revisione
ESBomRow.iProject = oDesignTrackingPropertySet.Item("Project").Value 'iProperties Progetto
ESBomRow.iDesigner = oDesignTrackingPropertySet.Item("Designer").Value 'iProperties Disegnatore
ESBomRow.iAuthority = oDesignTrackingPropertySet.Item("Authority").Value 'iProperties Autorità
ESBomRow.iCostCenter = oDesignTrackingPropertySet.Item("Cost Center").Value 'iProperties Centro Gestione Costi
ESBomRow.iCost = oDesignTrackingPropertySet.Item("Cost").Value 'iProperties Costo Preventivato
ESBomRow.iManufacturer = oDesignTrackingPropertySet.Item("Manufacturer").Value 'iProperties Fornitore
ESBomRow.iCatalogWebLink = oDesignTrackingPropertySet.Item("Catalog Web Link").Value 'iProperties Collegamento Web
' ----------Stato----------
ESBomRow.iUserStatus = oDesignTrackingPropertySet.Item("User Status").Value ' iProperties Stato
ESBomRow.iDesignStatus = oDesignTrackingPropertySet.Item("Design Status").Value ' iProperties Stato progetto
ESBomRow.iCheckedBy = oDesignTrackingPropertySet.Item("Checked By").Value ' iProperties Verificato da
ESBomRow.iDateChecked = oDesignTrackingPropertySet.Item("Date Checked").Value ' iProperties Data verifica
ESBomRow.iEngrApprovedBy = oDesignTrackingPropertySet.Item("Engr Approved By").Value ' iProperties Prog. Approvata da
ESBomRow.iEngrDateApproved = oDesignTrackingPropertySet.Item("Engr Date Approved").Value ' iProperties Data Approvazione Prog.
ESBomRow.iMfgApprovedBy = oDesignTrackingPropertySet.Item("Mfg Approved By").Value ' iProperties Prod. Approvata da
ESBomRow.iMfgDateApproved = oDesignTrackingPropertySet.Item("Mfg Date Approved").Value ' iProperties Data Approvazione prod.
' ---------- Personalizzate ----------
' Verifica iProperty Personalizzata/Proprietà istanza
If Not TypeOf oRow.ComponentDefinitions.Item(1) Is VirtualComponentDefinition Then
Dim component As Object = oRow.ComponentOccurrences(1)
Dim propertySet As PropertySet = Nothing
' Determina il tipo di componente e ottiene il propertySet corretto
If component.Type = ObjectTypeEnum.kComponentOccurrenceObject Then
Dim compOccurrence As ComponentOccurrence = CType(component, ComponentOccurrence)
If compOccurrence.OccurrencePropertySetsEnabled Then
propertySet = compOccurrence.OccurrencePropertySets(1)
End If
ElseIf component.Type = ObjectTypeEnum.kComponentOccurrenceProxyObject Then
Dim compProxy As ComponentOccurrenceProxy = CType(component, ComponentOccurrenceProxy)
If compProxy.NativeObject.OccurrencePropertySetsEnabled Then
propertySet = compProxy.NativeObject.OccurrencePropertySets(1)
End If
End If
' Se non ha trovato un propertySet valido, usa le iProperties personalizzate
If propertySet Is Nothing Then propertySet = oCustomPropertySet
' Assegna i valori delle proprietà
ESBomRow.iSpare = GetPropertyValue(propertySet, "Spare")
ESBomRow.iBoxNumber = GetPropertyValue(propertySet, "Numero Scatola")
Else
Try
ESBomRow.iSpare = oCustomPropertySet.Item("Spare").Value
Catch ex As Exception
End Try
End If
Try
ESBomRow.iLength = oCustomPropertySet.Item("Lunghezza").Value ' iProperties Lunghezza
Catch ex As Exception
End Try
Try
ESBomRow.iWidth = oCustomPropertySet.Item("Larghezza").Value ' iProperties Larghezza
Catch ex As Exception
End Try
Try
ESBomRow.iThickness = oCustomPropertySet.Item("Spessore").Value ' iProperties Spessore
Catch ex As Exception
End Try
Try
ESBomRow.iSection = oCustomPropertySet.Item("Sezione").Value 'iProperties Sezione
Catch ex As Exception
End Try
Try
ESBomRow.iGruoping = oCustomPropertySet.Item("Gruppo").Value ' iProperties Gruppo
Catch ex As Exception
End Try
Try
ESBomRow.iID = oCustomPropertySet.Item("ID").Value ' iProperties ID
Catch ex As Exception
End Try
Try
ESBomRow.iMark = oCustomPropertySet.Item("Marca").Value ' iProperties Marca
Catch ex As Exception
End Try
' ----------Fisiche----------
ESBomRow.iMaterial = oDesignTrackingPropertySet.Item("Material").Value ' iProperties Materiale
Try
ESBomRow.iDensity = Left(oRow.ComponentDefinitions.Item(1).Material.Density, 4) ' iProperties Densità
Catch ex As Exception
End Try
Try
ESBomRow.iMass = Left(oRow.ComponentDefinitions.Item(1).Material.Mass, 5) ' iProperties Mass
Catch ex As Exception
End Try
Try
ESBomRow.iArea = Left(oRow.ComponentDefinitions.Item(1).Material.Area, 5) ' iProperties Area
Catch ex As Exception
End Try
Try
ESBomRow.iVolume = Left(oRow.ComponentDefinitions.Item(1).Material.Volume, 5) ' iProperties Volume
Catch ex As Exception
End Try
' ----------Distinta componenti----------
ESBomRow.ItemNumber = oRow.ItemNumber ' Articolo Numero
ESBomRow.UnitQty = oRow.ComponentDefinitions.Item(1).BOMQuantity.BaseUnits ' Quantità di base
ESBomRow.ItemQuantity = oRow.TotalQuantity ' Quantità Elemento
ESBomRow.BomStructure = oRow.BOMStructure ' Struttura Distinta Componenti
'ESBomRow.Type = oRow.Merged
'ESBomRow.Public Property oType As String
'Iterate child rows if any
If oRow.ChildRows IsNot Nothing Then
FillBomRowsList(oRow.ChildRows, ESBomRows)
oType = 1
Else
oType = 0
End If
ESBomRow.oType = oType
'Append new value to List
ESBomRows.Add(ESBomRow)
Next
End Sub