AnsweredAssumed Answered

Help requested for macro to reset sheet formats

Question asked by Scott Wheeler on Sep 30, 2020
Latest reply on Oct 1, 2020 by Scott Wheeler

Hoping a bit of help can be lent here on a macro I started, but doesn't quite work how needed.  The ultimate intent is to have a macro reload a specific sheet template and also apply a specified drafting standard.  What I have below works to a point, but it is lumping in other sheet properties such as the drawing scale, which I do not want to adjust.  Is there a way to just change the sheet template and leave everything else the same? (Basically it list every parameter in the Sheet Properties dialog box)  TIA!

 

Dim swApp As Object
Dim swModel As SldWorks.ModelDoc2
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long

Sub main()

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc

'Check to make sure a file is open
If swModel Is Nothing Then
MsgBox "No current document", vbCritical
End
End If

'Check to make sure the file type is a drawing
If swModel.GetType <> swDocDRAWING Then
MsgBox "This Macro only works on Drawings", vbCritical
End
End If

Set Part = swApp.ActiveDoc
Dim myModelView As Object
Set myModelView = Part.ActiveView
myModelView.FrameState = swWindowState_e.swWindowMaximized
boolstatus = Part.Extension.LoadDraftingStandard("C:\EPDM\Templates\Drafting Standards\in.sldstd")


boolstatus = Part.Extension.SelectByID2("Sheet1", "SHEET", 0.199978233264952, 0.143048685243959, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
boolstatus = Part.SetupSheet5("Sheet1", 12, 12, 4, 1, False, "ANSI A in.slddrt", 0.4318, 0.2794, "Default", True)

' Zoom To Sheet
Part.Extension.ViewZoomtoSheet
End Sub

Outcomes