DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Searching through Channel Group names (DIAdem 2014)

Solved!
Go to solution

Hello,

 

I am using DIAdem 2014 and cannot seem to find code that works similar to the code listed below. When I try to run this code and other similar code I get the error - "Object doesn't support this property or method: 'Data.GetChannelgroups' "

 

The following example outputs the names of all channel groups whose names start with E:

Dim oMyChannelGroups, oMyChnGrp
Set oMyChannelGroups = Data.GetChannelgroups("E*")
For Each oMyChnGrp in oMyChannelGroups
  Call MsgBoxDisp(oMyChnGrp.Name)
Next

Link to code - http://zone.ni.com/reference/en-XX/help/370858M-01/inavidata/methods/diacmpnt_method_getchannelgroup...

 

Basically, what I would like to do is to use wildcards to find channel groups in the data portal with specific text. For purposes of this example, let's say that I want to search all channel groups in the data portal that contain the word "example" within the channel group name. If a channel group or multiple groups are found, then I would like to filter data channels within those channel groups.

 

I feel like it is important to note that I am running DIAdem 2014. 

 

Thank you in advance for your help.

0 Kudos
Message 1 of 7
(3,846 Views)

Hello rvillalta319,

The Data-API was extended in DIAdem 2015 with the method Data.GetChannelGroups. To use this method, you need at least DIAdem 2015. In your DIAdem 2014 it is not supported.

Greetings

Walter

0 Kudos
Message 2 of 7
(3,829 Views)

Walter,

 

Thanks for the reply. Do you know if there is an alternate method or line(s) of code to accomplish what I am trying to do?

 

Thanks,

 

0 Kudos
Message 3 of 7
(3,823 Views)
Solution
Accepted by topic author rvillalta319

You can try this here

 

dim oStrucView, oChnGroups, iLoop

set oChnGroups = Data.Root.ChannelGroups
set oStrucView = Portal.Structure
oStrucView.FilterForm.GroupFilterText = "S*"
portal.Structure.FilterForm.Expand(true)

for iLoop = 1 to oChnGroups.Count
  if oStrucView.IsElementDisplayed(oChnGroups(iLoop)) then
    msgbox oChnGroups(iLoop).Name
  end if
next

 

Greetings

Walter

Message 4 of 7
(3,818 Views)

This was a clever solution! I would have never thought to use the filter. I added this line after the code to clear the filter:

 

Portal.Structure.FilterForm.GroupFilterText("")

 

Thanks again for the help. This piece of code does exactly what I need it to do.

 

Cheers,

0 Kudos
Message 5 of 7
(3,814 Views)

Hello again,

 

Upon further developing my script I've encountered an issue for which I cannot seem find an explanation. Simply adding a ChnXYZAbsValue calculation before running this code you've provided me causes the filter not to work properly. It will only filter and display the first channel group that it finds with the set filter even though there are more groups that the filter applies to. See example code below. 

 

 

dim oStrucView, oChnGroups, iLoop

for iLoop = 1 to oChnGroups.Count
  Call ChnXYZAbsValue("["&iLoop&"]/X channel","["&iLoop&"]/Y channel","["&iLoop&"]/Z channel","["&iLoop&"]/Resultant")
next

set oChnGroups = Data.Root.ChannelGroups
set oStrucView = Portal.Structure
oStrucView.FilterForm.GroupFilterText = "S*"
portal.Structure.FilterForm.Expand(true)

for iLoop = 1 to oChnGroups.Count
  'works if I insert the calculation here
  if oStrucView.IsElementDisplayed(oChnGroups(iLoop)) then     msgbox oChnGroups(iLoop).Name   end if next oStrucView.FilterForm.GroupFilterText = "" Call Portal.Structure.ResetPinnedElements

It seems to work if I insert the calculation within the 2nd "for loop". But I need to keep both independent of each other.

 

Any thoughts are appreciated.

 

Thanks,

0 Kudos
Message 6 of 7
(3,754 Views)

**Update**

 

Solved the filtering problem above with the ChnXYZAbsValue calculation. All that is needed after the calculation is to refresh the data portal. The updated code is show below:

 

 

dim oStrucView, oChnGroups, iLoop

for iLoop = 1 to oChnGroups.Count
  Call ChnXYZAbsValue("["&iLoop&"]/X channel","["&iLoop&"]/Y channel","["&iLoop&"]/Z channel","["&iLoop&"]/Resultant")
next
Call Portal.Refresh
set oChnGroups = Data.Root.ChannelGroups set oStrucView = Portal.Structure oStrucView.FilterForm.GroupFilterText = "S*" portal.Structure.FilterForm.Expand(true) for iLoop = 1 to oChnGroups.Count 'works if I insert the calculation here if oStrucView.IsElementDisplayed(oChnGroups(iLoop)) then msgbox oChnGroups(iLoop).Name end if next oStrucView.FilterForm.GroupFilterText = "" Call Portal.Structure.ResetPinnedElements

 

0 Kudos
Message 7 of 7
(3,746 Views)