From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
06-28-2021 10:43 AM
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)?
Solved! Go to Solution.
08-17-2021 02:27 AM
In the Watch View we can see that it is an Array of Containers.
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?
08-17-2021 03:37 AM - edited 08-17-2021 03:41 AM
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)
08-17-2021 07:54 AM
Thank you so much. This works like a charm! I had given up on this like a month an a half ago 😂
08-17-2021 10:33 AM
It was difficult because it's counterintuitive. I was looking for attributes.
I ended up scanning all the properties 😄
11-04-2021 02:31 AM
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))