4 Replies Latest reply on Oct 22, 2018 4:55 PM by Brandon Brewer

    Using Input Card variables to build a file path for the Solidworks Task Add-in

    Jim Clark

      I'm trying to build a custom PDM task to print drawings as PDF's in a user-defined location.  To do this, I made a copy of the standard convert task, attached an input card which prompts the user to select a file location, and referenced that variable in the output path.  The problem is that it seems like the task isn't converting the variable name to its value.  Instead of the file path that was selected on the input card, the error log shows that it tried to print to %Print Location%\file.pdf


      Has anyone tried doing anything like this?  I've seen some posts about using data card variables but the solutions involved referencing the file; in this case, the variable isn't attached to any of the files that are being converted as it comes from the input card.  I also saw some articles that talked about referring to card variables using { } syntax but I'm not sure what exactly that means.




        • Re: Using Input Card variables to build a file path for the Solidworks Task Add-in
          Jim Clark

          For what it's worth, I was able to get it figured out.


          From what I gather, the task doesn't actually have a built in method to talk with variables that get set by an input card.  To force the task to take the variable value, you have to call out the variable in the script with both quotation marks and curly brackets.  For example, the code to build my file path looked like this:


          convFilePath = "{Print Location}" & "\"


          On my input card, I have a browse button to select the save location and writes it to the variable Print Location.  Note that if you use this method for creating a file path, you have to add another backslash at the end. 


          Also, in the task settings under Output File Details, you don't have to have any reference to the input card variable in the output path; the link to that variable just comes from the script.  If you do put a link to the input card variable in the output path definition, it doesn't seem to really do anything other than gum up the task.  I just used the output path definition to build my filename and the task worked out for me.


            • Re: Using Input Card variables to build a file path for the Solidworks Task Add-in
              Brandon Brewer

              Hello Jim,

              I am trying to do something very similar to what you did and are running into a similar error.


              My end goal is making PDF's of DWG files and saving them in a new folder.


              I am using a dispatch script to specify the new folder path and write it to a data card variable called "Folder PDF location" on the DWG data card. I then run a convert task to make the PDF's using the "Folder PDF Location" as the location of the PDF in same way as you are using your "Print Location". The task says it completes successfully but it does not actually make the PDF. Included some details below. Please let me know if you see anything that looks wrong.


              "Folder PDF Location" text from data card of DWG:

              Code to build file path:

              Output path: