Programmatically Adding a Step to Sequence from a Template in TestStand

Updated Oct 21, 2020

Reported In

Software

  • TestStand

Issue Details

I'm using the TestStand API to create a sequence file programmatically and as part of the process I'm considering to add to a Template Step available in the insertion palette. How can do that?

Solution

In the following steps you can find a procedure to create a new sequence file and insert a new step from the Templates pane:
  1. Get a reference to the current template file using the method Engine.GetTemplatesFiles.
  2. Then is possibile to get a reference to the template data using the reference of the Template files and the property PropertyObjectFile.Data.
  3. To create a new sequence file use the method Engine.NewSequenceFile.
  4. Get a reference to the MainSequence of the new sequence file using the method SequenceFile.GetSequenceByName.
  5. To create a new step using the method PropertyObject.Clone using the reference of the step you want to insert. To select and get a reference of the step you can use PropertyObject.GetPropertyObjectByOffset.
  6. To insert the new step in the MainSequence use Sequence.InsertStep.
  7. Then assign a unique StepId to the new step using Step.CreateNewUniqueStepIds.
  8. To save the new Sequence File use the method SequenceFile.Save and release the reference to it using the method Engine.ReleaseSequenceFileEx.

Additional Information

Refer to the Sequence File attached for an example (TestStand 2019). The example creates a new sequence file and insert a new step using the first step template.

For further details about for to create a Sequence File refer to Creating or Modifying a Sequence File from a Custom User Interface in TestStand.