1 Reply Latest reply on Sep 7, 2018 9:33 AM by Jim Clark

    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.

       

      Thanks,

      Jim

        • 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.