7 Replies Latest reply on Jan 13, 2015 8:11 AM by Michael Jonquiere

    PDF Export Macro from Workgroup PDM

    Steve Takata

      A while back I participated in a thread that addressed issues with SolidWorks Task Scheduler and some limitations with their "Export Workgroup PDM Files" function.  I was trying to use it to export the vault-generated PDF copies of all the drawings to a shared network location in our organization so our manufacturing group could have access to them, but not need SolidWorks to look at the actual drawing file and have the possibility of changing documentation.

       

      I could never get the Task Scheduler to run the "Export to local folder" option with PDFs correctly.  And I think when I got it to run once it put all the project files in a single folder.  So I wrote a macro to do a little better job with a few more options.  It is still a work in progress so make sure you watch it the first few times to make sure it behaves the way you expect.  I've tried to add plenty of comments, but please feel free to post questions or concerns here.

       

      So a quick summary of the macro:

      1. Log into the vault
      2. Iterate through all projects in the vault
      3. For each child project it will create a nested folder inside its parent, thereby recreating the whole project/folder structure
      4. Optionally check for custom properties of document as a condition of export
      5. Export the vaulted PDF drawing copies to the project specific folder
      6. Rename the PDF to be "filename_Revision.PDF"

       

      A couple of things I do not handle with this macro are old revisions and duplicate file names.  My practice right now is to periodically delete the entire directory structure and re-run the macro.  I was nervous to implement a large directory delete operation from the macro.  And if the macro encounters a PDF that already exists, then that file is skipped.  This should only be an issue if you have "Allow latest revision overwrite" enabled in your vault.  Attached here are the macro file and a text file of the same thing.  You will have to change the username, password, vault server and destination directory for the drawings for it to work on your system.

       

      One powerful tool is number 4 above.  I've made a duplicate of this macro to export "sales" drawings.  Once we as engineering review and approve a top-level drawing for release to customers, we add the custom property "PublicRelease" and set it to "Yes".  These property options could also be used to check lifecycle status before exporting.

       

      I need to give credit to Stephen Burke at http://solidworks.burkesys.com/category/macro/ for the core code of this macro for interfacing with the Workgroup PDM API.

       

      Good luck and let me know how it goes.

        • Re: PDF Export Macro from Workgroup PDM
          John Layne

          Great thanks for sharing this!

           

          Some nice to haves

               Exporting only specific project, not the whole content of the pdm server.

               Ability to export linked files (even if this means having multiple copies of the files in separate project folders)

           

          Really great to have--- ability to export as DXF (with sheetname filtering) When we create drawing of items that will be laser/plasma cut we add sheet to the drawing call DXF with only the profile of the item to be cut. Currently we manually save this sheet to the directory with the REV suffixed to the file, can get quite tedious.

          • Re: PDF Export Macro from Workgroup PDM
            Derek Lewis

            This works great!

             

            I agree with John... it would be nice to have something similar to this to export all vault files as DXFs (or STEP or IGES or etc.) while being able to control folders and file naming convention with a REV#, etc... 

             

            Have you seen any examples of using the Workgroup PDM API to actually open individual files from the vault, checking properties, and saving them as a different file type?

            • Re: PDF Export Macro from Workgroup PDM
              Daen Hendrickson

              This looks handy!

               

              Trying to modify to export attached (not imbedded) pdf files. Probably an easy mod if I had done any VBA in the last decade...

               

              I'll let you know how it goes.

               

              Daen

               

              ******* EDIT *********

               

              A little trial and error and I had this working in about 30 minutes. If I can do it then....

               

              I wanted to "dump" all our latest version PDF drawings for a project to put on a memory stick and take with me to the field.

               

              We do not use the Vault PDF creation function. We create PDFs from SW and attach them directly to the drawings within the vault. We also do this with *.DWGs and Word and Excel documents.

               

              My mods:

               

              I changed the vault login variables to our specific info

              I increased the excludeList() array to eliminate unwanted top level projects. I added the corresponding array elements below.

              I modified the rootDrawingPath to where I wanted the exports to go

               

              Within the CreateFolderCheckForChild function I modified:

              options.SearchCriteria.AddCriteria pdmwOr, pdmwDocumentName, "All", pdmwContains, "slddrw"

              into

              options.SearchCriteria.AddCriteria pdmwOr, pdmwDocumentName, "All", pdmwContains, "pdf"

              to find PDFs.

               

              options.SearchCriteria.AddCriteria pdmwAnd, pdmwUserDefinedProperty, "PublicRelease", pdmwContains, "Yes"

              into

              options.SearchCriteria.AddCriteria pdmwAnd, pdmwUserDefinedProperty, "Number", pdmwContains, "350"

              Our part numbers are keyed to projects. So all for this project start with 350... The attached PDF documents do not contain all the custom properties that a native SolidWorks file does so I could not search on our ProjectNumber property. If I were looking for the SLDDWR files, I would have searched on the ProjectNumber instead.

               

              In the For Each result In results loop I commented out all the code. The existing code extracts imbedded PDFs and renames them. I simply wanted to grab the PDFs I have already found in results and save them. I replaced all the code with this line:

               

              result.Document.Save (thisPath)

               

              That is it for the changes. I think this could easily be modified for the DWG, XLS, or DOC files.

               

              The biggest thing is patience once you run this. For me it looked like nothing was happening for a few minutes. Windows task manager was convinced things had stopped running. Then I saw folders and files starting to fill in my save to directory. I expect the initial parsing of the vault to populate the results takes a while.

               

              Hope this helps someone in my shoes.

               

              Daen

              • Re: PDF Export Macro from Workgroup PDM
                Alex Booth

                The Macro is great! thanks for putting this up.

                 

                We’re currently are using a projects database system (written in Microsoft Access) to share data around the company.

                Recently I had to create copies of the encrypted pdf files and manually place them into a directory locally (or on my desktop) to get them into the system. This is because I can’t navigate the WPDM database through Microsoft access.

                This Macro creates the copies of the pdf files now, which saves one step, but it’s still a little inefficient.

                 

                Our ideal function would be to only run the macro when a document has changed lifecycle status (i.e. from in design to released) and only copy the released pdf document from the vault into the specified directory.

                Our IT guy says he could then modify the project database to pick these files up and place them in the correct directory.

                I would also prefer it if would overwrite existing pdfs of the same name instead of skipping them as we often use the “read from file” on check in option to bump the revision.

                 

                We are looking into using the triggers function in WPDM admin tool to trigger the macro and then modifying the macro using date stamps to achieve the above?

                 

                 

                Do you think this is possible, or is it just a pipe dream?

                 

                 

                Alex

                • Re: PDF Export Macro from Workgroup PDM
                  Daniel Nichols

                  I found my way here before being notified by our VAR that there is a bug in SW2013 which has been addressed in SP3, SPR681698.

                   

                  I haven't tested whether I'll be able to export PDFs yet, but I wanted to document this here for the benefit of others