AnsweredAssumed Answered

Make .PNG of configuration

Question asked by None None on Mar 14, 2016
Latest reply on Mar 14, 2016 by Deepak Gupta

Hello fellow solidworkers,

 

I have been making a marco, when I actived It. It creates a .PNG of your current configuration with the configuration name as the name of the .PNG.

 

Now the problem:
If I have more then one configuration, I need to make .PNG go to the next configuration and make again a .PNG. It's labor intensive. So my question how can I make

the macro go to the next configuration and make a .PNG.

 

Code:

-----------------------------------------

Sub CreatePNG()

Dim sFilename           As String

Dim sConfigurationname  As String

Dim sDescription        As String

Dim sRevision           As String

Dim sBadChars           As String

Dim sCheck              As String

Dim sGetTitle           As String

Dim Chars               As Variant

 

 

 

 

Set swApp = Application.SldWorks

Set Part = swApp.ActiveDoc

 

sDescription = Part.CustomInfo("description")

sRevision = Part.CustomInfo("revision")

sFilename = Part.GetPathName

sGetTitle = Part.GetTitle

sConfigurationname = swApp.ActiveDoc.ConfigurationManager.ActiveConfiguration.Name

sBadChars = "\ / : * ? "" < > |"

sCheck = sRevision & " - " & sDescription

Chars = Split(sBadChars)

 

 

 

 

If (sFilename = "") Then

    Call swApp.SendMsgToUser("No file saved. Please save part or assembly file prior to running macro.")

Else

    If (sDescription = "") Or (sRevision = "") Then

        Call swApp.SendMsgToUser("Please fill in the description/revision.")

    Else

        sFilename = Left(sFilename, Len(sFilename) - Len(sGetTitle))

        Debug.Print "Creating .PNG File"

        sFilename = sFilename & "Bew. " & sConfigurationname & ".png"

        Part.SaveAs2 sFilename, 0, True, False

        Debug.Print "Finished"

    End If

End If

End Sub

Outcomes