how to automate filing a pdf of drawing with filename_revision into a specified directory?

how do i automate filing a pdf of drawing with filename_revision into a specified directory?

SolidworksDrawings And Detailing
Answers 21
DG
DG 2013-08-19 Best Answer

Welcome to SolidWorks forums Paul.

You can use macro to do it. Here are some post from where you can use the macro (you may have to edit them to suit the need).

https://forum.solidworks.com/message/151028#151028

https://forum.solidworks.com/message/200992#200992

https://forum.solidworks.com/message/158149#158149

https://forum.solidworks.com/message/321740#321740

https://forum.solidworks.com/message/138027#138027

You might also find this post helpful for your future reference.

PB
PB 2013-08-19

Thankyou for you fast reply. Guess i'll be using this forum more often.

Running the macro first time. 

Looking at using this one. https://forum.solidworks.com/message/151028#151028

first error

IMPORTANT! sheet name 'sheet1' not named according to procedure.

What is the procedure ?

DG
DG 2013-08-20

Try this macro. You would need to set the path first:

  1. Go to Tools > Macro > Edit and browse to this file.
  2. This will open the macro.
  3. Now change C:\Test to your required path. Make sure you path is in quotes i.e. it should look like "C:\Test".
  4. Save the macro and open your drawing.
  5. Run the macro and check the results.
PB
PB 2013-08-21

Works well thankyou very much....You have been very kind.

Just one more thing, if possible, is that our placement for the pdf files is one directory below the solidworks drawing location. Solidworks drawings are filed in different locations but always the pdf is one directory down. The directory name funny enough is .\PDF.

Would like to allow yes/no  to over file if there is a duplicate and to move previous lower revision if they exist to  ..\trunk

DG
DG 2013-08-21
<p>if possible, is that our placement for the pdf files is one directory below the solidworks drawing location. </p>

Yes can be done. Just change the path to whatever you want. And In case you the path will change based on each project then please give me one path example for drawings and PDF and I'll see if that can be set in the macro itself.

<p>Would like to allow yes/no  to over file if there is a duplicate</p>

Yes can be done. The macro will pop up with Yes OR NO buttons.

<p><span style="font-size: 10pt;">move previous lower revision if they exist to  </span><strong style="font-size: 10pt;">..\trunk</strong></p>

I'll have to check this.

PB
PB 2013-08-21

In bold is the common portions of the file locations.

user name in the directory stucture will change depending on who is loged on.

Working directory 1.1 (the open SW drawing location)

Place for lates pdf file revisiond 2.1.

place for old revisions of pdf files 3.1.

  1. LOCATION OF SOLIDWORKS FILE OPENED IN SOLIDWORKS
    1. C:\Users\paulb\Documents\My Work Files\NTMS MECHANICAL\5060 Thermal Camera\ME5060-2-90-008_THERMAL CAMERA AND FLP ENCLOSURE ASSEMBLY – ANALOGUE VIDEO OUTPUT\trunk\
  2. LOCATION OF LATEST REVISION PDF FILES
    1. C:\Users\paulb\Documents\My Work Files\NTMS MECHANICAL\5060 Thermal Camera\ME5060-2-90-008_THERMAL CAMERA AND FLP ENCLOSURE ASSEMBLY – ANALOGUE VIDEO OUTPUT\trunk\PDF\
  3. LOCATION OF OLD REVISION PDF FILES
    1. C:\Users\paulb\Documents\My Work Files\NTMS MECHANICAL\5060 Thermal Camera\ME5060-2-90-008_THERMAL CAMERA AND FLP ENCLOSURE ASSEMBLY – ANALOGUE VIDEO OUTPUT\tags

FYI. We are using SubVersion for version control to a central database.

DG
DG 2013-08-22

Testing some methods/codes on it. Looks like all of these can be done

DG
DG 2013-08-26

Not able to move old PDFs with my macro. Can you do that manually and my macro will do the others.

PB
PB 2013-08-26

maybe pause the macro at this point to force the user to do this (maybe just a note on the screen that says to complete this task before proceeding.. move old version and to do subversion add for both.

DG
DG 2013-08-27

That can be done.

PB
PB 2013-09-02

I do appriciate what you are doing.

Have you had any luck with the macro ?

DG
DG 2013-09-03

Just making final codes for setting the path and everything else is set up. Should be able to upload the macro in a day or two.

PB
PB 2013-09-23

how is it proceeding?

DG
DG 2013-09-24

Hi Paul, got side tracked with some medical emergency. Will finish up the macro soon.

DG
DG 2013-10-05

Sorry for a long delay, here is the macro. Give it a shot and let me know how it worked.

DG
DG 2013-10-06

Did you changed anything in the macro??? If yes then please revert that back i.e. don't change anything in the macro and try again.

DG
DG 2013-10-09

Paul did you had any luck with the macro yet??

DG
DG 2013-10-10

Sorry Paul there was a typo in the code. Kindly use following line and remove the old ones (basically remove the back slash after PDF)

<p><strong>If Dir(User & sFilePath & "PDF") = "" Then</strong></p><p><strong>MkDir User & sFilePath & "PDF"</strong></p><p><strong>End If</strong></p>

Not sure why but same macro works fine for me.

PB
PB 2013-10-10

Actual location C:\Users\paulb\Documents\My Work Files\NTMS MECHANICAL.

comment imagecomment imagecomment imagecomment imagecomment imagecomment image
DG
DG 2013-10-11

The macro is working fine for me.

Can you please edit the macro as shown below and check:

<p>User = Environ("USERPROFILE")</p><p>User = User & FilePath</p><p>Debug.Print User </p><p></p><p>sFilePath = Left(swModel.GetPathName, InStrRev(swModel.GetPathName, "\"))</p><p>sFilePath = Mid(sFilePath, (Len(User) + 1))</p><p>Debug.Print sFilePath</p><p>   </p><p>FileName = Mid(swModel.GetPathName, InStrRev(swModel.GetPathName, "\") + 1)</p><p>FileName = Left(FileName, InStrRev(FileName, ".") - 1)</p><p></p><p></p><p>Value = swModel.CustomInfo2("", "Revision")</p><p>If Value = "" Then</p><p>MsgBox "Please add Revision property OR value and try agian."</p><p>End</p><p>End If</p><p></p><p>Debug.Print User & sFilePath & "PDF"</p>

And let me know what you see in the immediate window. Also make sure you're logged in as Paulb and not Paulb.NTMS.

DG
DG 2013-10-14

Here is another macro with slight changes. Can you try this one.

Also did you tried the one macro with changes I posted above? If yes, then what was the result.