2 Replies Latest reply on Jan 14, 2018 1:17 PM by Logan Pegler

    PDF Task export all pages except named page

    Logan Pegler

      Hi there,


      I have slowly been setting up our PDM Professional system and migrating data in. All is going fairly smoothly but I have slowly come up with a list of "nice to haves". One of which is to do with the PDF export.


      We currently have an approval transition setup so that when a file is approved, the drawing generates a DXF and a PDF.

      All of our drawings have named sheets along the lines of: PROFILE, BENDING, DXF etc. There are about 8 in total for different part/assembly requirements.


      The DXF task is working exactly as desired. In the PDM options it allows you to specify to export only sheets with a particular name. So we are able to put in DXF here and it will only output the DXF page from the drawing.


      However, as the DXF page often has a part off page, it would be desirable to have the PDF output all pages EXCEPT the DXF page. This is not an option available in the standard interface.

      I understand that these tasks can be modified through the "Advanced Scripting Options" in the task dialog and have done so to get the revision output on the name how we wish. Is it also possible to use this to achieve the export of all pages except the DXF page for our PDF export task? And if so how?


      I'm also open to any other methods we could use to achieve this? I would like to stay away from having to create multiple drawings of the same part/assembly to achieve this.


      Kind Regards



        • Re: PDF Task export all pages except named page
          Ulf Stockburger

          Hi Logan


          I assume you are familiar with VBA and know how to customize the Convert Task. Expand the script's ability to negate the sheet name. Here is an example. Changes are based on the default SolidWorks Convert Task. In this case Version 2014.


          Declare a global variable and a constant. The variable contains the sheet name, which can be given in the Convert Task dialog. The constant contains the characters for negation.

          Dim negSheet As String

          Const negChar = "!"


          Copy the page name into the variable and check whether you want to negate them. If so, the variable is given the sheet name, otherwise it is empty. Insert this code below into the Sub main.

          Sub main()

          On Error GoTo Fail:


              negSheet = "[NamedSheet]"

              If VBA.Left(negSheet, VBA.Len(negChar)) = negChar Then

                  negSheet = VBA.Right(negSheet, VBA.Len(negSheet) - VBA.Len(negChar))


                   negSheet = ""

              End If

               . . .

          End Sub


          Replace this If Statement in Sub Convert below the comment 'Named sheet:

          If Not SheetName Like "[NamedSheet]" Then

              removed = removed + 1

          End If

          with this one:


          If negSheet <> "" Then

              If SheetName Like negSheet Then

                  removed = removed + 1

              End If

          ElseIf Not SheetName Like "[NamedSheet]" Then

              removed = removed + 1

          End If


          If you comment out 'Stop, you will enter the debug mode of SolidWorks-CAD during execution and can see what happens.

          If you now give the sheet name !DXF in Sheets to output , everything except DXF will be converted.


          It's not really tested, but I'm sure it will work. Hope it helps.


          BiI SAP-PDM