12-04-2015 01:57 PM
I am trying to use the "shift + F2" key sequence to collapse all the data partal groups in Diadem 2012.
Assigning the script file to function button works, it just doesn't work when using the shift function key sequence.
Here is the code:
dim oGroups, iGroupLoop
set oGroups = Data.Root.ChannelGroups
For iGroupLoop = 1 To oGroups.Count
If Portal.Structure.IsExpanded (Data.Root.ChannelGroups(igrouploop)) Then
Call Portal.Structure.Collapse(Data.Root.ChannelGroups(igrouploop))
End If
next
What would be best for me would be to add this to a icon button for quick usage.
Several searches have turned up information, but none have been able to fix the function key colapse.
12-05-2015 09:31 PM
Hi jbelow2,
Have you tried right-clicking on the Root element in the Data Portal tree view and selecting the "Collapse Groups" menu?
Brad Turpin
DIAdem Product Support Engineer
National Instruments
12-06-2015 08:56 AM
Hi Brad,
Thanks for the reply, that is how I do it, but it becomes very annoying when I have lots groups with lots of channels. I have tried to add the script lines to other scripts and not to the function key, but still doesn't work. My script all add calculated channels to all my groups, which causes the groups to expand. So I find myself always either using the "+","-" key or right clicking as you suggest to collaspe.
Late last night, I was hitting the function key numerous times in a row and wallop... it worked. So I added a "pause" to my script and it seems to work every time except for the lengthy time delay.
In VBA there is a command "DoEvents" will this work here? I am going to try this tomorrow when back in the office. I think I might be onto something here and hope to either optimize the delay times or hopefully get the "DoEvents" function to work.
I will let you know how things go..
Thank You
John
12-07-2015 09:51 AM
I have fixed it.
For collasping the data portal using the script tied to a function key, I created a looping function which repeats the command until finished. By pressing the shortcut for the function key, it would always work, though by using the key strokes "Shift & F2" it would always fail. By repeatedly pressing the "Shift &F2" I sometimes saw a group or two collaspe, so I thought to try to repeat until Diadem registered the groups collasped. It now works everytime for the "Shift & F2" key sequence. My other problem of closing programmatically was fixed by setting the UIAutoRefreshSet variable to true.
Examples of both solutions are as follows:
'function key portal collapsing script Dim otestgrp, vbmsg, ogroups SET oGroups = Data.Root.ChannelGroups FOR each otestgrp in oGroups DO CALL Portal.Structure.Collapse(otestgrp) LOOP until portal.Structure.IsExpanded(otestgrp) = false NEXT
To fix the problem to close the groups programmatically, I had to set the UIAutoRefreshset to "true" prior to the closing script.
'portal collapsing script DIM oTest, oMyGrps SET oMyGrps = Data.Root.ChannelGroups Call UIAutoRefreshSet(True) for each oTest in oMyGrps if Portal.Structure.IsExpanded(oTest) then Call Portal.Structure.Collapse(oTest) NEXT
I hope others find this useful.
John
12-08-2015 07:52 AM
Hi John,
For the case that you want to minimize certain Groups after a script runs, there's a trick you need to know. I'm happy you found a hotkey solution, but I thought you might also want to implement certain group open/closed states at the end of some of your scripts. The default behavior of DIAdem is not to update the Data Portal while a VBScript is running-- which really helps VBScripts run much faster. It is possible, though, to temporarily toggle DIAdem into the state where Data Portal updates do happen, using the UIAutoRefreshSet() command, like this:
Call Data.Root.Clear Call DataFileLoad(DataFilePath, "DataPluginName") Call UIAutoRefreshSet(1) Call Portal.Structure.Collapse(Data.Root) Call UIAutoRefreshSet(0)
Brad Turpin
DIAdem Product Support Engineer
National Instruments