1 Reply Latest reply on Dec 12, 2014 2:39 PM by Tara Campese

    How to create a PDF based off of a data card variable

    Tara Campese

      I have a variable called "Cleaning Required" on the data card of all of my drawings.  When a specific macro is run by the user, that check box gets marked. Once any drawing is approved a PDF is created.  What I want is in addition to the currently generated PDF, I would like a second PDF generated based on if that "Cleaning Required" check box has a value of 1.  Ideally, I would just modify the secondary output path of the task add-in script to Save a second PDF with "-Cleaning" if the variable is present.  But I can't figure out how to check for the variable in this script. 


      I tried changing the existing script to: (changes in bold)


      ‘Checks variable for cleaning

      Function GetFileVariable(sVarName As String)
      sVarVal = swModel.CustomInfo2("",“Cleaning Required”))
      GetFileVariable = sVarVal

          If GetFileVariable = 0 then GoTo Here:

      End Function


          If bSecondOutput = True Then

              convFileName2 = Replace(convFileName2, "<Filename>", modelFileName)

              convFileName2 = Replace(convFileName2, "<Extension>", modelExtension)


              convFilePath2 = Left(convFileName2, InStrRev(convFileName2, "\"))

              CreatePath convFilePath2

              convFileName2 = convFileName2 & ext

          End If


      Sub main()



          On Error GoTo Fail:


          Set FileSystemObj = CreateObject("Scripting.FileSystemObject")

          docFileName = "<Filepath>"


          ' Get SW interface object

          Set swApp = Application.SldWorks

          swApp.Visible = True    'SPR 682792, 538578, 651998

          Convert docFileName


          Exit Sub


      I have looked through the forums and have not been able to find an answer to this question.  Solution S-052490 appears to be on the right track, but still not exactly what I need. Any help is appreciated.


      Thank you,



      PS I am running SW 2014 SP4.0 and Enterprise PDM 2014

        • Re: How to create a PDF based off of a data card variable
          Tara Campese

          After reading up more on using the GoTo labels, I realized that I could not use them in that way.  I have tried rewriting the code with that in mind and came up with this:



              Dim convFileName2 As String

              convFileName2 = "[OutputPath2]"

              Dim convFilePath2 As String

              Dim convFileNameTemp2 As String

              Dim sVarVal As String


              Dim bSecondOutput As Boolean


              ‘Checks variable for cleaning

              sVarVal = swModel.CustomInfo2("",“Cleaning Required”)

          If sVarVal = 1 then

          bSecondOutput = True


                                  bSecondOutput = False

                      End If


          The code works when the value for "Cleaning Request" is 1 or 0, but it is still getting hung up when the variable "Cleaning Request" isn't present.  I want bSecondOutput to be false if there is no variable present.  I tried using a msgbox to debug, but it doesn't seem like this script allows for message boxes; I tried adding one to the default script and it failed.