12 Replies Latest reply on Apr 27, 2016 11:22 AM by Lee CS Young

    Convert Task - Replace existing file with file name change

    Paul Smith

      Hi,

       

      We've recently added a task to our workflow to convert models to parasolids upon approval. When this is performed we'd like to add the revision of the model to the end of the file name i.e. <Source File Name>_Rev<Source File Rev>.x_b

       

      When the model is revised and approved the revision increments, so if the first file name was <Source File Name>_RevA.x_b, the second is <Source File Name>_RevB.x_b

       

      The problem we have is that we want the new file to replace the old one, but because the file name is changing the "Replace existing files" option in the Convert task doesn't work.

       

      Is there a way to get the new file to overwrite the old, or even a way to automatically delete the old when the new is created?

       

      I would have thought this kind of functionality would be included in EPDM, but my search so far has led me to believe it will be a somewhat complex work around.

       

      EDIT: I know it would be easier to just not include the revision in the file name, but at this stage, that is not an option.

        • Re: Convert Task - Replace existing file with file name change
          Michael Dekoning

          Paul,

          This functionality is not needed for PDM as the system retains the older versions of the files. The revision can be shown on the data card. I suppose you could update the Task code to rename the file after the existing one is replaced.

            • Re: Convert Task - Replace existing file with file name change
              Paul Smith

              Michael,

               

              Because the file is being renamed it is not creating versions to store the old revisions, rather it is adding a new file every time the part is revised. The main reason we want the revision in the file name is so there is a way to tell what revision the file is once it is outside the vault, when this happens there is no longer data card information to determine revision.

               

              Are you suggesting to modify the Task code so it is saved without the revision in the file name, then the revision is added afterwards? However wouldn't the same problem occur when the file is revised? Because when the task is run on the revised file, attempting to overwrite the existing file, the name wouldn't match and therefore would just save another version?

            • Re: Convert Task - Replace existing file with file name change
              Paul Smith

              Could I use a dispatch script that is triggered by the source file being released? To search for the file name, and use either the revision information or last modified date to delete the old x_b?

                • Re: Convert Task - Replace existing file with file name change
                  Marvin Stettner

                  Paul,

                   

                  if i understood correct, i have a question:

                  Why it  need to get the file name with the revision? If you create a filename with the basics it also can be overwrite the existing file.

                  I create a property for export files, in this value the pdm system writes what you want.

                  In this case, the revision...

                   

                  Greetings

                    • Re: Convert Task - Replace existing file with file name change
                      Paul Smith

                      Hi Marvin,

                       

                      The main reason the revision needs to be in the file name is so that the revision can be identified outside the vault. Using a property or data card information only helps show the revision if the file is not moved.

                       

                      Our vault is a database of drawings for use by other departments such as supply and manufacturing. They take the files from the vault and package them up in their own way outside the vault. For drawings this works fine because they can open the PDF and the revision is written on the drawing, but x_b files don't provide such a simple solution.

                       

                      Thanks,

                      Paul

                    • Re: Convert Task - Replace existing file with file name change
                      Lee CS Young

                      You could do this by editing the script the convert task uses. Shouldn't be too difficult.

                        • Re: Convert Task - Replace existing file with file name change
                          Paul Smith

                          Hi Lee,

                           

                          I'm not much of a programmer. I've been unsuccessful in searching around for some information on how to implement something like this in the script.

                           

                          Can you point me in the direction of examples of modifying the script to implement this function? Aside from ensuring a valid file name is used, I can't even find where in the script it uses the output path information that is entered into the 'Output File Details' of the Convert properties.

                           

                          Cheers,

                          Paul

                            • Re: Convert Task - Replace existing file with file name change
                              Lee CS Young

                              If you have access to the knowledgebase there are a few examples on how to modify the script and how to debug it. Start there. I'd write this up for you but I don't have the time at the moment.

                               

                              I also noticed some related links on this post that may give you some ideas. Some have done it with Dispatch.

                                • Re: Convert Task - Replace existing file with file name change
                                  Paul Smith

                                  Hi Lee,

                                   

                                  I've created a dispatch command to delete previous revision files where the revision is attached at the end of the file name, last character before the .x_b extension. I'm testing it out at the moment, so I'm using a menu command to run the dispatch command.

                                   

                                  I have created the following variables:

                                  Alpha                                   ABCDEFGHIJKLMNOPQRSTUVWXYZ

                                  DotPosition                         Find(%NameOfSelectedFile%, .)

                                  RevPosition                        Sub(%DotPosition%, 1)

                                  Revision                              Mid(%NameOfSelectedFile%, %RevPosition%, 1)

                                  RevNumber                        Find(%Alpha%, %Revision%)

                                  PreviousRevNumber          Sub(%RevNumber%, 1)

                                  PreviousRevision               Mid(%Alpha%, %PreviousRevNumber%, 1)

                                  FilenameNoRev                 Left(%NameOfSelectedFile%, %RevPosition%)

                                  OldFilename                       %FilenameNoRev%%PreviousRevision%.x_b

                                   

                                  In the command window I have simply entered:

                                  Type: Delete file

                                  Content: DELETE %DirOfSelectedFile%\%OldFilename%

                                   

                                  I also added an Ok MessageBox which displays all of the above variables. The %DirOfSelectedFile%\%OldFilename% looks correct. I am testing it on a file that has a RevA and RevB.  When I run it on RevB it returns the name and path of the RevA file, but does not delete it. So it would seem all the variables are working correctly but the Delete file command isn't doing anything.

                                   

                                  I tried adding a Block START and Block END before and after the delete File command in case that might change anything, it still will not delete the old revision file.

                                   

                                  Any ideas on what isn't working?

                                   

                                  Thanks,

                                  Paul

                                    • Re: Convert Task - Replace existing file with file name change
                                      Paul Smith

                                      Slightly embarrassing...

                                       

                                      There is a check box to also remove file from vault, without this checked it only deletes local files. All seems to be working now.

                                       

                                      I also added a 0 (zero) as the first character in the variable Alpha. I've got the dispatch to be triggered by x_b files doing the transition to released. When it was attempting to run on revision A files the task was was failing because it couldn't figure out what it was supposed to delete. I also added a Jump into the command window, so that IF %Revision% = A then GOTO End.

                                       

                                      It seems to be working. I had to remove the OK Message Box, otherwise the server wouldn't finish the task until the message box was OK'd.

                                    • Re: Convert Task - Replace existing file with file name change
                                      Paul Smith

                                      I'm fairly happy with how it's working.

                                       

                                      One thing I've noticed though, if somebody has accessed the x_b file, after it is deleted from the vault, they can still see a local file. Is there any way to tidy this up?

                                       

                                      I guess people could clear their cache, but if there is some way this could be automated that would be great.