batch process format swap
batch process format swap
(OP)
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






RE: batch process format swap
Regards,
Scott Baugh, CSWP
FAQ731-376: Eng-Tips.com Forum PoliciesGEASWUG Greater Evansville Area SWUG Leader
www.scottjbaugh.com
RE: batch process format swap
The tricky thing is the notes that you've added to the current sheet format during drawing creation. I'm sure that the sheet format had some notes in it already when the drawing was created. Those notes (I assume) do not go over to the new sheet format. Only the "extra" ones that were added during drawing creation. How would the macro know which notes were the ones that need to go over? The only thing I can think of is that you would have to create a fresh, new "dummy" sheet using the old sheet format. Then the macro would have to compare content of each note of the sheet you want to transfer with the "dummy" sheet and only transfer notes that don't appear on the "dummy" sheet.
The rest of the tasks are relatively straightforward, it'll just take some time to write. If time is something you have less of, I can make a good recommendation on a hired API gun or two.
-handleman, CSWP (The new, easy test)
RE: batch process format swap
handlean- hoping to crete new sheet format with notes addition in part properties.
This format would be available for new projects. Exsting I agree would pose prob;ems. Thanks