swforge1
Mechanical
- Jun 23, 2010
- 39
Hi All
Been experimenting with the attached macro with success. Trying to add functionality and are loking for help from the more knowlegible. The macro swaps a drawing format to another specified in the macro.
I would like to automate and have it:
detect existing format and sheet size
swap out to modified format-same size
kepp all notes i sheet format(added manualy at creation of drawing)
keep notes in drawing, idealy same relative position if possible
all in batch process-files form specified folder
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim i As Long
Dim bRet As Boolean
Dim vSheetName As Variant
Dim swSheet As SldWorks.Sheet
Sub Main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
vSheetName = swDraw.GetSheetNames
For i = 0 To UBound(vSheetName)
bRet = swDraw.ActivateSheet(vSheetName(i))
'Put any sheet format name
swDraw.SetupSheet4 vSheetName(i), swDwgPaperCsize, 12, 1, 1, False, "C:\Users\Desktop\CreateFolder\Formats\C-Size.slddrt", 0#, 0#, "Default"
'Put the required sheet format name
swDraw.SetupSheet4 vSheetName(i), swDwgPaperDsize, 12, 1, 1, False, "C:\Users\Desktop\CreateFolder\Formats\D-Size.slddrt", 0#, 0#, "Default"
swModel.ViewZoomtofit2
Next i
' Switch back to first sheet and change format
bRet = swDraw.ActivateSheet(vSheetName(0))
'Put the required sheet format name
swDraw.SetupSheet4 vSheetName(0), swDwgPaperDsize, 12, 1, 1, False, "C:\Users\Desktop\CreateFolder\Formats\D-Size.slddrt", 0#, 0#, "Default"
swModel.ForceRebuild3 (False)
swModel.Save
End Sub
Been experimenting with the attached macro with success. Trying to add functionality and are loking for help from the more knowlegible. The macro swaps a drawing format to another specified in the macro.
I would like to automate and have it:
detect existing format and sheet size
swap out to modified format-same size
kepp all notes i sheet format(added manualy at creation of drawing)
keep notes in drawing, idealy same relative position if possible
all in batch process-files form specified folder
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim i As Long
Dim bRet As Boolean
Dim vSheetName As Variant
Dim swSheet As SldWorks.Sheet
Sub Main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
vSheetName = swDraw.GetSheetNames
For i = 0 To UBound(vSheetName)
bRet = swDraw.ActivateSheet(vSheetName(i))
'Put any sheet format name
swDraw.SetupSheet4 vSheetName(i), swDwgPaperCsize, 12, 1, 1, False, "C:\Users\Desktop\CreateFolder\Formats\C-Size.slddrt", 0#, 0#, "Default"
'Put the required sheet format name
swDraw.SetupSheet4 vSheetName(i), swDwgPaperDsize, 12, 1, 1, False, "C:\Users\Desktop\CreateFolder\Formats\D-Size.slddrt", 0#, 0#, "Default"
swModel.ViewZoomtofit2
Next i
' Switch back to first sheet and change format
bRet = swDraw.ActivateSheet(vSheetName(0))
'Put the required sheet format name
swDraw.SetupSheet4 vSheetName(0), swDwgPaperDsize, 12, 1, 1, False, "C:\Users\Desktop\CreateFolder\Formats\D-Size.slddrt", 0#, 0#, "Default"
swModel.ForceRebuild3 (False)
swModel.Save
End Sub