I have made a macro from various bits from this user group.
All it does is open all files in a folder 1by1 - rebuilding it - and saving them again.
I am sure you can gather the pieces to make a macro to suit your needs (just add the call for fit and zoom, also iso is a standard named view so that is easy also).
I would like to add that my macro in its current form is used on a speciel type of file (slddrw or sldasm or sldprt) but you can just make a loop to make it able to work on all.
In my expirience dont run it with more than 100-200 files a pop, since you will continue to fill the SW memory with this kind of macro that works from inside SW (and dosnt reboot it after each file).
Here it goes:
Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.DrawingDoc =B4this you would have to make a loop with to be used for the different file types .AssemblyDoc and .PartDoc Dim ReturnVal As Long Dim Response As String Dim DocName As String Dim Success As Boolean Dim DocType As String Dim swUpper As String Dim swDocTypeLong As Long
Const workDir =3D "C:\YourFolderWithFiles\" Const swDocType =3D ".SLDDRW" =B4here you set the type of files you want to open
Const readOnly =3D 0 ' 0-false 1-true Const viewOnly =3D 0 ' 0-false 1-true Const silent =3D 1 ' 0-false 1-true
' start of main program Set swApp =3D Application.SldWorks swApp.Visible =3D True ChDir (workDir) Response =3D Dir(workDir) Do Until Response =3D "" ' see if filename ends with .SLDDRW or which filetype you putted as swDocType swUpper =3D UCase$(Response) If Right(swUpper, 7) =3D swDocType Then
' open the SolidWorks file (this bit can handle all the 3 types of SW files, this is done so I can easily what between file types just by changing swDocType and swModel) If UCase$(swDocType) =3D ".SLDPRT" Then swDocTypeLong =3D swDocPART ElseIf UCase$(swDocType) =3D ".SLDASM" Then swDocTypeLong =3D swDocASSEMBLY ElseIf UCase$(swDocType) =3D ".SLDDRW" Then swDocTypeLong =3D swDocDRAWING Else Stop 'Error Occured End If
Dim swName As String swName =3D workDir & Response
Dim nErrors As Long Dim nWarnings As Long
Set swModel =3D swApp.OpenDoc6(swName, swDocDRAWING, swOpenDocOptions_e.swOpenDocOptions_Silent, "", nErrors, nWarnings)
=B4HERE you can add the call for fit and iso view (I dont recall it and dont have time to look it up)
DoEvents
swModel.ForceRebuild3 False
DocName =3D swModel.GetTitle ReturnVal =3D swModel.Save2(silent)
swApp.CloseDoc DocName Set swModel =3D Nothing
End If
' get the next filename
Response =3D Dir Loop
Set swApp =3D Nothing End Sub
I hope this will help you get there. Or I am sure many others can fill in the missing parts.