01-11-2021 10:32 AM
I am working on a custom Data Plugin, that should import a file by using another DataPlugin, then make some adjustments (more specifically, add some meta-tag, change group names).
I was able to add the meta-tags I needed, but apparently I cannot modify group names.
Some notes on the plugin configuration (see also the attached picture)
Below you can find the basic structure of my script. I anticipate that I know some functionalities are not available in .vbsd files, but I was hoping it would be possible to load a file by using another plugin, and then perform operations such as group name updates.
I also tried to replace Root with Data.Root, but it doesn't work either.
Do you think there is a way to have those names updated?
Sub ReadStore(MyFile)
' Import File
Call Root.ImportStore(MyFile, "MDF3") ' It works
' Add Meta-tags
Call Root.Properties.Add("TagName", "TagValue") ' It works
' Rename Group
Root.ChannelGroups(1).Name = Root.ChannelGroups(1).Properties("description").Value ' Not working
End Sub
Solved! Go to Solution.
01-14-2021 04:57 PM - edited 01-14-2021 04:58 PM
Hi panta,
When I'm creating a post-processing DataPlugin that uses another DataPlugin to parse the file, I always re-create the desired hierarchy fresh from the Root object and just assign the properties and channel values from each corresponding "StoreObject", like this:
Sub ReadStore(Store)
Dim StoreRoot, StoreGroup, Group
Set StoreRoot = Store.Children(1)
Call Root.Properties.AddProperties(StoreRoot.Properties)
FOR Each StoreGroup In StoreRoot.Children
Set Group = Root.ChannelGroups.Add(StoreGroup.Name)
Call Group.Properties.AddProperties(StoreGroup.Properties)
Call CreateChannels(StoreGroup, Group)
NEXT ' StoreGroup
End Sub
Sub CreateChannels(StoreGroup, Group)
Dim StoreChannel, Channel
FOR Each StoreChannel In StoreGroup.Channels
Set Channel = Group.Channels.AddStoreChannel(StoreChannel)
NEXT
End Sub
In the above example, I using the StoreGroup.Name property to name the corresponding Root.ChannelGroup, but that would be your opportunity to name the Root.ChannelGroup something different-- at the moment you create it.
Brad Turpin
Principal Technical Support Engineer
NI
01-15-2021 03:40 AM - edited 01-15-2021 03:41 AM
Hi Brad,
That is brilliant! Exactly what I was looking for. I've just checked and it works! Thanks a lot, with your advice I can make the activity I'm about to carry out way easier and more efficient!