NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically insert folder into Templates>Steps

Solved!
Go to solution

I am creating a dynamic step template creator sequence. The steps are split saved in different folders under. Templates>Steps. I want the create the subfolders programmatically so the folder do not have to be created before hand,  Is there a way to programmatically insert a subfolder into the Templates>Steps (see image attached)? 

 

 

 

RktScientist97_0-1624894759249.png

 

0 Kudos
Message 1 of 6
(1,388 Views)

In the Watch View we can see that it is an Array of Containers.

Template.png

However, when I tried to add an Array of Containers it was not shown as a folder but as... an Array of Containers... I don't see any special attributes nor properties to mark it as a folder...

 

The workaround could be to clone one of the folders that are already in the templates list or import some dummy folder from a file and adjust to what you need.

 

Can you show the approach u used to insert templates?

Michał Bieńkowski
CLA, CTA, CPI

  1. Did someone devote their time to help solve your problem? Appreciate it and give kudos.
  2. Problem solved? Accept as a solution so that others can find it faster in the future.
  3. Contribute to the development of TestStand by voting on the TestStand Idea Exchange.
0 Kudos
Message 2 of 6
(1,300 Views)
Solution
Accepted by topic author RktScientist97

Ok I figured it out. It is a comment 😄

You need to create an Array of Containers (in example Locals.Folder) and comment it with NI_TEMPLATE_CATEGORY.

Then simply use this:

RunState.Engine.GetTemplatesFile(0).Data.Root += {Locals.Folder},
RunState.Engine.GetTemplatesFile(0).IncChangeCount(),
RunState.Thread.PostUIMessageEx(UIMsg_RefreshWindows, 0, "", Nothing, True)

Michał Bieńkowski
CLA, CTA, CPI

  1. Did someone devote their time to help solve your problem? Appreciate it and give kudos.
  2. Problem solved? Accept as a solution so that others can find it faster in the future.
  3. Contribute to the development of TestStand by voting on the TestStand Idea Exchange.
Message 3 of 6
(1,297 Views)

Thank you so much. This works like a charm! I had given up on this like a month an a half ago 😂

0 Kudos
Message 4 of 6
(1,287 Views)

It was difficult because it's counterintuitive. I was looking for attributes.

 

I ended up scanning all the properties 😄

Michał Bieńkowski
CLA, CTA, CPI

  1. Did someone devote their time to help solve your problem? Appreciate it and give kudos.
  2. Problem solved? Accept as a solution so that others can find it faster in the future.
  3. Contribute to the development of TestStand by voting on the TestStand Idea Exchange.
0 Kudos
Message 5 of 6
(1,277 Views)

I realized that if you use RunState.Engine.GetTemplatesFile(0).Data.Root += {Locals.Folder} to insert an item, Templates are kind of frozen until you restart TS. To fix it, use the Clone() method as below:

Locals.TemplatesFile.AsPropertyObjectFile.Data.Root.SetPropertyObjectByOffset(GetNumElements(Locals.TemplatesFile.AsPropertyObjectFile.Data.Root), PropOption_InsertElement, Locals.FolderPlaceholder.Clone("", PropOption_NoOptions))

Michał Bieńkowski
CLA, CTA, CPI

  1. Did someone devote their time to help solve your problem? Appreciate it and give kudos.
  2. Problem solved? Accept as a solution so that others can find it faster in the future.
  3. Contribute to the development of TestStand by voting on the TestStand Idea Exchange.
0 Kudos
Message 6 of 6
(1,202 Views)