Using the API, every BOM has a version of 1, linked to the drawing file (but without knowing the revision of the drawing). Is this possible?
Here is the P.O.C. code snippet I'm currently working with:
Public Function TryGetBom(Of _EdmBomType As IEdmBom)(ByRef bom As _EdmBomType, ByRef exception As Exception) As Boolean
Dim derivedBoms As EdmBomInfo() = Nothing
Try
Dim bomMgr As IEdmBomMgr = Nothing
If Vault.TryCreateUtility(EdmUtility.EdmUtil_BomMgr, bomMgr, exception) = False Then
Return False
End If
If TryGetDerivedBoms(derivedBoms, exception) = False Then
Return False
End If
For bomIndex As Integer = 0 To derivedBoms.Length - 1
Dim id As Integer = derivedBoms(bomIndex).mlBomID
'Dim bom As IEdmBom = Nothing
Dim versions As EdmBomVersion() = Nothing
If Vault.TryGetObject(EdmObjectType.EdmObject_BOM, id, bom, exception) = False Then
Continue For
End
If
bom.GetVersions(versions)
For versionIndex As Integer = 0 To versions.Length - 1
Console.WriteLine("{0} - {1}) {2} - {3}", bom.Name, versionIndex, versions(versionIndex).mbsTag, versions(versionIndex).mlVersion)
Dim bomLayouts As EdmBomLayout() = Nothing
bomMgr.GetBomLayouts(bomLayouts)
For bomLayoutIndex As Integer = 0 To bomLayouts.Length - 1
Dim bomView As IEdmBomView = Nothing
Try
bomView = File.GetComputedBOM(bomLayouts(bomLayoutIndex).mbsLayoutName, versions(versionIndex).mlVersion, "", EdmLib.EdmBomFlag.EdmBf_AsBuilt)
Catch ex As Exception
Continue For
End Try
Next
Next
Next
Return False
Catch ex As Exception
exception = ex
Return False
End Try
End Function
Thanks!
SolidworksApi macros