Stop display states from making really large part file

If you create or delete a lot of configurations in a macro, the part file will get tremendously large. If you don't care about hidden elements (suppressed is okay), you should delete display states to keep the file size controlled. Example: I manually deleted the display states and my part went from 70MB to 2 MB!

Here is how to do it inside a macro,

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swPart As SldWorks.PartDoc

Sub main()

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swPart = swModel

    swPart.RemoveAllDisplayStates

End Sub

SolidworksApi macros