Hi,
I have a macro whose intent is to cycle through all the views on my drawing (multiple sheets) and set each view property to true (checked) and the BOM name to the name of the BOM on the drawing, happens to be Bill of Materials1. The code has a provision which finds the name of this BOM on its own.. Anyhow, when I run this code, only some view properties update, most do not. The views that update correctly are views of the top level assembly which the BOM is based on, the views that it doesn't work on are views of the individual pieces on subsequent sheets that are just components of this top level assembly. Any ideas why this would be happening? CODE:
Dim swApp As SldWorks.SldWorks
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 = 0
Do 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
Loop
retVal = swDrawing.ActivateSheet(vSheetNames(0))
Set 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