Here is a macro question
I downloaded a macro that will change the sheet format in a given folder. it works amazingly. The only problem I am having with it is it will result in a default scale of 1:1 and it will not change the sheet format on other sheets of a document, only the current one.
I have posted the code below.
' Change_Sheet_Format.swp ---------------------------------08/10/09
' Original Code taken from Zoom and Rebuild macro
' Author: Luke Malpass, Paul Kellner 2004 (super rebuild), Pete Farnham
' Website: http://www.angelsix.com' Prerequisites: Set the directories having drawings you wish to run the
' change sheet format, set the new sheet format location and sheet format name
'
' Macro will find all the drawing files in the specified folder/location and
' replace the existing sheet format with the new one. Might delete everything contained
' within the format.' ------------------------------------------------------------------------------
' Written by: Deepak Gupta (http://gupta9665.wordpress.com/)
' ------------------------------------------------------------------------------Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim swFilename As String
Dim swDraw As SldWorks.DrawingDoc
Dim swSheet As SldWorks.Sheet
Dim bRet As Boolean
Dim sPath As String
Dim nErrors As Long
Dim nWarnings As Long
Dim Response As String
Dim DocName As String
' Change sheet format location here
Public Const sTemplatePath As String = "C:\Jobs 2010\Template\"
Sub main()
Set swApp = Application.SldWorks
' Change folder location containing the drawings to be updated here
SheetFormat "C:\Jobs 2010\Job # 11068\06 REAR Bowl Feeder\", ".SLDDRW", True
End Sub
Sub SheetFormat(folder As String, ext As String, silent As Boolean)
Dim swDocTypeLong As Long
ext = UCase$(ext)
swDocTypeLong = Switch(ext = ".SLDDRW", swDocDRAWING, True, -1)
'If not a SW file, return
If swDocTypeLong = -1 Then
Exit Sub
End If
ChDir (folder)
Response = Dir(folder)
Do Until Response = ""
swFilename = folder & Response
If Right(UCase$(Response), 7) = ext Then
Set swModel = swApp.OpenDoc6(swFilename, swDocTypeLong, swOpenDocOptions_Silent, "", nErrors, nWarnings)
If swDocTypeLong = swDocDRAWING Then
Set swDraw = swModel
Set swSheet = swDraw.GetCurrentSheet
' Change Sheet format name here which you to put on the drawing sheet.
sPath = sTemplatePath & "RPP DRAWING.SLDDRT"
bRet = swDraw.SetupSheet4(swSheet.GetName, swDwgPaperAsize, swDwgTemplateCustom, 1, 1, False, sPath, 0.2794, 0.2159, "Default")
End If
swModel.ViewZoomtofit2
swModel.ForceRebuild3 False
swModel.Save2 silent
swApp.CloseDoc swModel.GetTitle
End IfResponse = Dir
LoopMsgBox "Drawing(s) Sheet Fomat Updated!!"
End Sub
Highlighted in green is the parameters that one would change folder of template, folder to update drawings, and template name. Whats in red is what I beleive makes the new scale 1:1
I was hoping to find out if
1: there is a way to have the scale the same as the original drawing after updating template, and
2: (not necessary) have this macro update drawings with multiple sheets
This macro is the work of
Deepak Gupta (http://gupta9665.wordpress.com/)
Any help would be much appreciated!
Thank you