Hi,
I've adapted some macros that I've found in this forum to save out my drawing for a specified range of configurations. I have 2 drawing sheets and want to be able to select one sheet only depending on the range of configurations I select. Currently it prints both sheets every time.
I presume it's because I have vSheets at an Integer variant, but every time I try and change this with something else I think it disrupts vViews, so I'm lost here. Total beginner with macros but trying to learn as I go. Been watching LinkedIn Learning videos too.
I've attached the code but here it is too:
Const OUTPUT_FOLDER = "C:\\Users\\Anna\\Documents\\Anna Temp\\SW\\Macro\\OUTPUTS\\R_3"
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swRefModel As SldWorks.ModelDoc2
Sub main()
Dim i As Integer
Dim vConfs As Variant
Dim swView As SldWorks.View
Dim confName As String
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Set swView = swDraw.GetFirstView().GetNextView
Set swRefModel = swView.ReferencedDocument
vConfs = swRefModel.GetConfigurationNames
' Select configuration range to save
For i = 6 To 8
confName = vConfs(i)
ProcessViews confName
swModel.ForceRebuild3 False
boolstatus = swModel.Extension.SaveAs(OUTPUT_FOLDER + confName + "1_RevA.pdf", swSaveAsVersion_e.swSaveAsCurrentVersion, swSaveAsOptions_e.swSaveAsOptions_Copy, Nothing, 0, 0)
Next i
MsgBox "Completed"
Set swApp = Nothing
Set swModel = Nothing
Set swDraw = Nothing
Set swRefModel = Nothing
End Sub
Sub ProcessViews(confName As String)
Dim i As Integer
Dim vSheets As Variant
Dim j As Integer
Dim vViews As Variant
Dim swFeat As SldWorks.Feature
Dim swView As SldWorks.View
vSheets = swDraw.GetViews
For i = 0 To UBound(vSheets)
vViews = vSheets(i)
For j = 0 To UBound(vViews)
Set swView = vViews(j)
swView.ReferencedConfiguration = confName
Next j
' Update FeatureManager design tree
swDraw.ForceRebuild
Next i
Set swFeat = Nothing
Set swView = Nothing
End Sub
SolidworksApi/macros