9 Replies Latest reply on Jul 8, 2014 11:14 AM by Shawn Pantzke

    improving Convert task

    Greg Rupp

      I was just curious if anyone has improved the default "convert task" to be better in some way?


      For example, I would love for the convert task to have better error handling/ error messaging. When a convert task is ran and it tries to check in the newly created file under a name that already exists, we get just the general "Task Failed" and no info about why. I would really like for the system to throw an error saying "File name is not unique". Even better would be to rename the original an Save the new.


      Any other suggestions or solutions please post.

        • Re: improving Convert task
          Jeff Sweeney

          Possibly the easiest way to improve Convert task is with the Advanced Scripting options.


          You can't completely change how the task runs, but you actually have quite a bit of customization power in there.

            • Re: improving Convert task
              Tim Webb



              Two questions:

              1. Is it possible to reference the EdmLib using Imports EdmLib in the convert to PDF advanced scripting option?
              2. The file with custom properties being modified is inside EPDM which requires locking the file, changing the value, and unlocking it. How is that done?
              3. I would like to set the variable value on the data card of the slddrw being converted to PDF. Do you know how to do that in the advanced scripting editor?




                • Re: improving Convert task
                  Jeff Sweeney

                  I've never found a way to reference libraries in the advanced scripting. The task simply takes the advanced scripting text, substitutes its special variables with values from the tasks and makes a temporary SW macro from it. You have access to the SW libraries, (because they are automatically added to all new macros) but that is it.


                  [Maybe you could figure out a way to have SW load your EPDM library too for every macro by default??? But then you would have to do this on every machine.]


                  Just declare everything as the basics...object, strings, integers, etc. [i.e. late binding for you VB nerds]


                  As a tip, write the code in SW VBA, test it with the libraries, then just before you finish, change your objects to "Objects" and test without the library. If you did it right, everything should still work.


                  This answers #2 and #3 as well, everything works the same as you always have....just harder.

                    • Re: improving Convert task
                      Jeff Sweeney

                      I did find that this line of code loads the library at runtime...

                      Application.VBE.ActiveVBProject.References.AddFromFile "C:\Program Files (x86)\SolidWorks Enterprise PDM\EdmInterface.dll "

                      Which is rather interesting, but it doesn't fool the IDE intreface, it still doesn't like the objects within the library. Maybe someone else has an idea of how to continue from here?

                      • Re: improving Convert task
                        Shawn Pantzke

                        has anyone out there found a way to change the default libraries in solidworks so that it will automatically pull the EPDM library or others for that matter? This would be most helpful for me as I have a dedicated machine for running tasks.



                      • Re: improving Convert task
                        Jeff Sweeney

                        You say two questions, but I count three?

                        • Re: improving Convert task
                          Tor Iveroth

                          You can reference the EPDM API via the advanced task script by defining the vault object as:


                          Dim vault As Object

                          Set vault = CreateObject("ConisioLib.EdmVault")


                          Then you can run EPDM API calls on files processed by the SolidWorks task add-in.  Have a look at the script in the default design checker task (c:\program files\solidworks enterprise pdm\default data\DesignChecker_Gb.cex).  KB solutions S-054527 and S-061104 shows how to modify the convert script to get variables from source file data card.


                          Regarding updating the source file values, I'd recommend doing that via transition action "set variable" instead of via the script as you might end up with timing problems or file access problems if manipulating the source file at the same time the task is trying to process it in SW.


                          -Tor Iveroth, EPDM support