AnsweredAssumed Answered

Need Macro for #included drawing while saving Part file with new name.

Question asked by Kishore K. on Feb 6, 2018
Latest reply on Feb 11, 2018 by Kishore K.

Hi folks,

 

I need to save a existing file with new name along with reference drawing.

I have code what it does? It will save as existing file with new name in different location and it will change configuration name too as per the file name. But the problem here I dknow  how to included reference drawing, it has to save as along with new part file and with new name.

 

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

 

    Dim vConfNameArr            As Variant

    Dim sConfigName             As String

    Dim i                                 As Long

    Dim configNames             As Variant

    Dim ConfigName              As String

    Dim swConfig                As Configuration

    Dim configArray()           As Variant

Sub main()

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

'Save as window

    swModel.Extension.RunCommand swCommands_SaveAs, Empty

'Change configuration names

   

    vConfNameArr = swModel.GetConfigurationNames

 

 

    For i = 0 To UBound(vConfNameArr)

 

 

        sConfigName = vConfNameArr(i)

        swModel.ShowConfiguration2 sConfigName

        Debug.Print i; "."; " Config = " & sConfigName

  

swApp.ActiveDoc.ConfigurationManager.ActiveConfiguration.Name = swApp.ActiveDoc.GetTitle()

Next i

swApp.ActiveDoc.ConfigurationManager.ActiveConfiguration.Name = "FLATPATTERN-" & swApp.ActiveDoc.GetTitle()

swModel.ShowConfiguration2 swApp.ActiveDoc.GetTitle()

configNames = swModel.GetConfigurationNames

For i = 0 To UBound(configNames)

ConfigName = configNames(i)

Set swConfig = swModel.GetConfigurationByName(ConfigName)

MsgBox ("Config Name:(" & i & ") = " + ConfigName)

configArray = Array(configNames)

Next i

End Sub

Attachments

Outcomes