1 Reply Latest reply on Aug 17, 2017 9:35 AM by Aaron Larson

    Trying to update template card variables from API

    Alex Steinberg



      I'm trying to write a quick script to handle all of our legacy data migration. I've created a template for our job files, and what I'd like the script to do is to first run the template, and fill in the variables on the data card. Then I'd just copy the files into the new folders and check everything in.


      I've used the example http://help.solidworks.com/2014/English/api/epdmapi/Execute_Template_Example_CSharp.htm to get a console application going that will run the template, but I cannot figure out how to programmatically populate the fields in the card for projectNumber projectName and customer. My C# code is shown below.


      namespace TemplateCaller


          class Program


              static int Main(string[] args)


                  if (args.Length < 3)


                      System.Console.WriteLine("Please enter arguments of the form projectNumber projectName customer");

                      return 1;


                  string projectNumber = args[0];

                  string projectName = args[1];

                  string customer = args[2];

                  IEdmVault5 vault5 = new EdmVault5();

                  IEdmVault8 vault8 = (IEdmVault8)vault5;

                  vault8.Login("admin", "VisserCast78","VPC");

                  IEdmTemplateMgr5 templateMgr = default(IEdmTemplateMgr5);

                  templateMgr = (IEdmTemplateMgr5)vault8.CreateUtility(EdmUtility.EdmUtil_TemplateMgr);

                  IEdmPos5 templatePos = templateMgr.GetFirstTemplatePosition();

                  IEdmTemplate5 template = null;





                      template = templateMgr.GetNextTemplate(templatePos);

                      if (template.GetMenuString() == "Create Job")








                  return 0;







        • Re: Trying to update template card variables from API
          Aaron Larson

          Not sure if you figured this out... but this seems to be what you're looking for.  I was in a similar situation.  My application had a card button that launched a custom form.  Purpose of the form was to provide checked listbox items based on the selection of a dropdown (I needed multi-select ability for the items).  This functionality is required both on the file card as well as the template card.  The methods in the API help for getvar/setvar focused only on datacards with files.... nothing on template cards.  The method in the link worked perfectly.