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
<p style="font-size: 14px; font-family: Verdana, 'Verdana Ref', Geneva, Tahoma, sans-serif; color: #333333;">Dim swApp As SldWorks.SldWorks<br>Private Const strApp As String = "Link2BOM v1.00"</p><p style="font-size: 14px; font-family: Verdana, 'Verdana Ref', Geneva, Tahoma, sans-serif; color: #333333;">Public Sub subMain()<br> Dim iCnt, iTotal As Integer<br> Dim retVal As Variant<br> Dim sBOMname As String<br> Dim vSheetNames As Variant<br> <br> Dim swView As SldWorks.View<br> Dim swSheetView As SldWorks.View<br> Dim swModel As SldWorks.ModelDoc2<br> Dim swDrawing As SldWorks.DrawingDoc<br> Dim swFeat As SldWorks.Feature<br> Dim swBOM As SldWorks.Feature<br> <br> Set swApp = Application.SldWorks<br> Set swModel = swApp.ActiveDoc<br> Set swDrawing = swModel<br> Set swFeat = swModel.FirstFeature<br> <br> 'Get BOM name<br> Do While Not swFeat Is Nothing<br> If "BomFeat" = swFeat.GetTypeName Then<br> Set swBomFeat = swFeat.GetSpecificFeature2<br> Set swBOM = swBomFeat.GetFeature<br> sBOMname = swBOM.Name<br> Exit Do<br> End If<br> Set swFeat = swFeat.GetNextFeature<br> Loop<br> <br> vSheetNames = swDrawing.GetSheetNames<br> iTotal = UBound(vSheetNames) + 1<br> iCnt = 0</p><p style="font-size: 14px; font-family: Verdana, 'Verdana Ref', Geneva, Tahoma, sans-serif; color: #333333;"> Do While iCnt < iTotal<br> 'Set view linked to BOM<br> retVal = swDrawing.ActivateSheet(vSheetNames(iCnt))<br> Set swSheetView = swDrawing.GetFirstView<br> Set swView = swSheetView.GetNextView<br> Do While Not swView Is Nothing<br> retVal = swView.SetKeepLinkedToBOM(True, sBOMname)<br> Set swView = swView.GetNextView<br> Loop<br> iCnt = iCnt + 1<br> Loop</p><p style="font-size: 14px; font-family: Verdana, 'Verdana Ref', Geneva, Tahoma, sans-serif; color: #333333;"> retVal = swDrawing.ActivateSheet(vSheetNames(0))<br> <br> swApp.SendMsgToUser2 " Linking is complete... ", swMbInformation, swMbOk</p><p style="font-size: 14px; font-family: Verdana, 'Verdana Ref', Geneva, Tahoma, sans-serif; color: #333333;"> Set swApp = Nothing<br> Set swModel = Nothing<br> Set swDrawing = Nothing<br> Set swFeat = Nothing<br> Set swBomFeat = Nothing<br> Set swBOM = Nothing<br> Set swSheetView = Nothing<br> Set swView = Nothing<br> <br> End<br>End Sub</p>
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