Save As macro of a .slddrw file using the name of the active configuration

Hi all

I work in a company in the medical sector that uses SolidWorks 2018. We regularly have to go from hundreds of prototype plans to "customer" plans. I managed to find macros to perform most of the operations. I still have to find a last one that would allow me to rename the .slddrw plans by the name of the active configuration on each plan. To simplify the operation, you would need a macro capable of doing the following operation with a plan already saved and open :

- "Save As" using the name of the active configuration on each plan 

After a lot of research on different forums I unfortunately did not find a similar case, which is why I take the liberty of opening this topic.

Thanks in advance,

Daniel

Hello

The following code allows you to save the plan with a file name corresponding to the name of the configuration of the last view analyzed on this plan.

Kind regards

Dim swApp As Object
Dim swModel As SldWorks.ModelDoc2
Dim swDraw As SldWorks.DrawingDoc
Dim swView As SldWorks.View
Dim nameDrw As String

Sub main()

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swDraw = swModel
    
    Set swView = swDraw.IGetFirstView

    Do While Not swView Is Nothing
        nameDrw = swView.ReferencedConfiguration
        Set swView = swView.GetNextView
    Loop

    swModel.SaveAs nameDrw & ".slddrw"
    
End Sub
1 Like

Great, thank you so much for that quick response! I'll test it tomorrow morning.