5 Replies Latest reply on Jul 27, 2018 8:39 AM by Keaton Warn

    Generating .PDF and .DWG with macros

    Nathan McCluskey

      Hi, I posted this on another thread about 4 weeks ago but I didn't get responses. I was wondering if anybody would be kind enough to make me a macro to suit my workflow a little bit better.

      I would like to be able to press CTRL+Shift+S and it to bring up the Save as menu and run the macro. I can then save the drawing with a file name.


      When I then save the file as a .slddrw file I would like the macro to complete the below tasks:

      1, Save a .DWG with the same file name as the .slddrw drawing.

           The .DWG to have a file location on the server. Location: N:\5. DWG Files

      2, Save a .PDF with the same file name as above but to also include ' - 'Revision' e.g. Drawing1 - Rev A.

           The .PDF to have a file location on the server. Location: G:\Master Drawings\Provisional Drawings\2. Design Spec Drawings


      The revision is linked in my drawing via line 10 on the custom properties and gets updated when I add in a revision table. See the below image.



      Thank you for your time

        • Re: Generating .PDF and .DWG with macros
          Robert H.

          to be honest that would just waste time,  you only need to export a pdf or dwg when you happy with the drawing not every 5 minutes, its called export for a reason, there are lots of Marco that do what you want, have look, look though my posts i have one you could use with a bit of mortification 

            • Re: Generating .PDF and .DWG with macros
              Nathan McCluskey

              Thanks for getting back to me Robert.


              I agree with you with a normal manufacturing drawing. We are currently creating an online database so our sales team and customer to download models/drawings. Setting up the first drawing will take some time but having over 300 products to complete just changing over the configuration and rename the file this will save the extra 3/4 clicks per drawings.  


              The save location would get changed but I wanted to be able to understand the macro if I needed it to be modified.


              I don't know much about macros hence the CTRL+SHIFT+S which I thought would still allow me to save maufacturing drawings like normal.


              I will have a look through your other threads and see if I can piece together a macro.

                • Re: Generating .PDF and .DWG with macros
                  Robert H.

                  in that case i wouldn't be that hard to set up a Marco to save standard location or multiple/ locations - this could be reflected in you drawing properties -  that reflect there save location on your online platform,


                  you could set up a macro to open up all the files drawing files in a dir and save them out if you have 300+ prepared drawings to save out


                  it not that hard



                  if you want to call protptes you can do it like this






                  Set swApp = Application.SldWorks

                  Set SWmoddoc = swApp.ActiveDoc





                  'Naming Convention - (DOCUMENT PROPERTIES)

                  ' ----------------------------------------



                  PRO_NAME = SWmoddoc.CustomInfo("TITLE")



                  PROJECT_No = SWmoddoc.CustomInfo("PROJECT_No.")


                  or in your case  revision = SWmoddoc.CustomInfo("revision")


                  and to save somthing like this


                  swDraw.SaveAs (Filepath & "PDF\" & NAMCON & ".pdf")


                  Filepath  is a variable - setin the marco/ program - it could be generated  of the drawing file - or set to you preferred save location 

              • Re: Generating .PDF and .DWG with macros
                Robert H.

                i could give you mine as an example but it might be a bit confusing,


                have a look at this link / marco


                Generating .PDF and .DWG with macros


                i would help you some more but am off early today !!! 

                • Re: Generating .PDF and .DWG with macros
                  Keaton Warn

                  From what I understand, to save the most time you want a macro to find all of the .slddrw files in a folder and then save PDFs and DWG versions to a new folder with the revision letter. I've been messing with SW VBA macros for only this summer and I can confidently say this is something even I could write (albeit it would take longer than someone like Keith Rice or Deepak Gupta). For my first macro, I wrote code that does a Pack and Go to a .zip folder in a Revisions directory and makes PDFs of the drawings to a PDF directory, and all of these files are marked with "-[Revision Letter]" after the part number.


                  There is a small chance someone already has a publicly available file for you to run. However, if time is of the essence, I would contact your VAR or one of the experienced macro/API guys on these forums and pay them to write some custom code for your project.


                  If your company utilizes PDM, you can probably have this run as a task every day or maybe have it triggered in your workflow whenever a new revision is created. Again, contact your VAR for clarification. Mine has been easy to work with.