I am attempting to redraw several dozen drawings to have a more presentable bank of drawings. I am trying to incorperate a macro to redraw all of the configurations and have it place them in the appropriate views. I'm also trying to link revisions from the part to the drawing files so when a new revision is added to a part, it will automatically insert the revision into the drawings. This would save a lot of time opening and adding a single revision to several dozen drawings is time consuming. If you have any suggestions with either the macro or simply adding the revisions, I would appreciate it. Also if I could incorperate the dimensions properly into each drawing. I also don't want it to create and save each drawing back to back. I would like to look at each one as it is drawn and I decide to save and move on to the next. I'm not very good at writing code.
I've managed to correct some of the minor errors but I am not experienced enough with macros.
This is the macro I'm trying to work with:
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim vConfs As Variant
Dim i As Integer
Dim sDrTemplate As String
Dim lDrSize As Long
Const sOutputFolder As String = "E:\Drawings\"
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
sDrTemplate = swApp.GetUserPreferenceStringValue(swUserPreferenceStringValue_e.swDefaultTemplateDrawing)
lDrSize = swDwgPaperSizes_e.swDwgPaperA0size
vConfs = swModel.GetConfigurationNames()
For i = 0 To UBound(vConfs)
Set swDraw = swApp.NewDocument(sDrTemplate, lDrSize, 0, 0)
swDraw.Create1stAngleViews2 swModel.GetPathName
Dim swView As SldWorks.View
Set swView = swDraw.GetFirstView
While Not swView Is Nothing
swView.ReferencedConfiguration = vConfs(i)
Set swView = swView.GetNextView
Wend
Dim swDrawModel As SldWorks.ModelDoc2
Set swDrawModel = swDraw
swDrawModel.ForceRebuild3 False
swDraw.InsertModelAnnotations3 swImportModelItemsSource_e.swImportModelItemsFromEntireModel, 32776, True, True, False, False
swDrawModel.Extension.SaveAs sOutputFolder + swModel.GetTitle() + "_" + vConfs(i) + ".slddrw", swSaveAsVersion_e.swSaveAsCurrentVersion, swSaveAsOptions_e.swSaveAsOptions_Silent, Nothing, 0, 0
swApp.CloseDoc swDrawModel.GetTitle()
Next
End Sub