Hi all,
I use this code to find the BOM name.
But I need its configuration. Keep in mind that it is a top level only BOM
Dim swApp As SldWorks.SldWorks
Private Const strApp As String = "Link2BOM v1.00"Public Sub subMain()
Dim iCnt, iTotal As Integer
Dim retVal As Variant
Dim sBOMname As String
Dim vSheetNames As Variant
Dim swView As SldWorks.View
Dim swSheetView As SldWorks.View
Dim swModel As SldWorks.ModelDoc2
Dim swDrawing As SldWorks.DrawingDoc
Dim swFeat As SldWorks.Feature
Dim swBOM As SldWorks.Feature
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDrawing = swModel
Set swFeat = swModel.FirstFeature
'Get BOM name
Do While Not swFeat Is Nothing
If "BomFeat" = swFeat.GetTypeName Then
Set swBomFeat = swFeat.GetSpecificFeature2
Set swBOM = swBomFeat.GetFeature
sBOMname = swBOM.Name
Exit Do
End If
Set swFeat = swFeat.GetNextFeature
Loop
vSheetNames = swDrawing.GetSheetNames
iTotal = UBound(vSheetNames) + 1
iCnt = 0Do While iCnt < iTotal
'Set view linked to BOM
retVal = swDrawing.ActivateSheet(vSheetNames(iCnt))
Set swSheetView = swDrawing.GetFirstView
Set swView = swSheetView.GetNextView
Do While Not swView Is Nothing
retVal = swView.SetKeepLinkedToBOM(True, sBOMname)
Set swView = swView.GetNextView
Loop
iCnt = iCnt + 1
LoopretVal = swDrawing.ActivateSheet(vSheetNames(0))
swApp.SendMsgToUser2 " Linking is complete... ", swMbInformation, swMbOkSet swApp = Nothing
Set swModel = Nothing
Set swDrawing = Nothing
Set swFeat = Nothing
Set swBomFeat = Nothing
Set swBOM = Nothing
Set swSheetView = Nothing
Set swView = Nothing
End
End Sub
Whatever I try
Dim sBOMconfig As Variant
Dim swBomFeat As SldWorks.BomFeature
Dim swFeat As SldWorks.Feature
Set swFeat = swModel.FirstFeature
Set swBomFeat = swFeat.BomFeature (or Set swBomFeat = swFeat.GetSpecificFeature2)
sBOMconfig = swBomFeat.GetConfigurations(True, Visible)
I cannot seem to get the configuration being used.
Further I would also like to see it only look for the configuration of the visible BOM. All other BOM's in the sheet that are hidden should be ignored.
SolidworksApi macros