Is there a way to freeze and save a file without opening it? Here's the macro I made to freeze every part in an open assembly (lifesaver when I have over 8000 parts).
' MODULE: FREEZE PARTS
' PROGRAMMER: DMITRY ZAMOSHNIKOV
' DATE: 11/13/2013
' PURPOSE:
' GO THROUGH AN ASSEMBLY AND FREEZE EVERY PART IN THE ASSEMBLY.
' FUNCTION: FREEZE_ALL
' IN: NONE
' OUT: ALL PARTS==FROZEN?
'
Dim swdoc As SldWorks.ModelDoc2
Dim swAllDocs As EnumDocuments2
Dim FirstDoc As SldWorks.ModelDoc2
Dim boolstatus As Boolean
Dim NumDocsReturned As Long
Dim DocCount As Long
Dim swapp As SldWorks.SldWorks
Dim longstatus As Long
Dim part As Object
' FREEZE_ALL
' WHILE (PARTS IN ASSEMBLY NOT FROZEN > 0 )
' OPEN PART
' FREEZE PART
' SAVE PART
' CLOSE PART
' WEND
Public Sub FREEZE_ALL()
Set swapp = Application.SldWorks
Set swAllDocs = swapp.EnumDocuments2
Set FirstDoc = swapp.ActiveDoc
DocCount = 0
swAllDocs.Reset
swAllDocs.Next 1, swdoc, NumDocsReturned
' This loop will go through all of the documents within an assembly, including sub-assemblies.
While NumDocsReturned <> 0
bDocWasVisible = swdoc.Visible ' Use Hidden Parts
' script crashed if an attempt to freeze an assembly is made.
' check the file to make sure it's a "sldprt" file.
If (UCase(Right(swdoc.GetPathName, 6)) = UCase("sldprt")) Then
swapp.ActivateDoc2 swdoc.GetPathName, True, longstatus 'open and activate the part
boolstatus = swdoc.FeatureManager.EditFreeze(swMoveFreezeBarTo_e.swMoveFreezeBarToEnd, "", True) ' move the freeze bar to the end
swdoc.SaveAs (swdoc.GetPathName) ' save the change
swapp.CloseDoc (swdoc.GetTitle()) ' close the part
End If
swAllDocs.Next 1, swdoc, NumDocsReturned ' Go to the next part
DocCount = DocCount + 1 ' Keep a count of all parts within the assembly, including sub-assemblies.
Wend
End Sub
Sub FREEZE_ONE()
Set swapp = _
Application.SldWorks
Set part = swapp.ActiveDoc
boolstatus = part.FeatureManager.EditFreeze(swMoveFreezeBarTo_e.swMoveFreezeBarToEnd, "", True)
part.SaveAs (part.GetPathName)
'swapp.CloseDoc part.GetTitle()
End Sub