Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Scripting_function



Panel
titleDescription

Returns a list of nodes found at the specified path. The list objects are returned as dictionaries with some basic information about each node.


Panel
titleClient Permission Restrictions

This scripting function has no Client Permission restrictions.


Panel
titleSyntax

  system.tag. browse( path, filter )

  • Parameters 

String path - The path that will be browsed, typically to a folder or UDT instance.

PyDictionary filter - A dictionary of browse filter keys. Keys are listed below.

  • Returns

Results - A Results object which contains a list of tag dictionaries, one for each tag found during the browse. Use getResults() on the results object to get the list of tag dictionaries, or getReturnedSize() to get the number of tags returned by the browse.

  • Scope

Gateway, Vision Client, Perspective Session


Panel
titleFilter Keys

The following keys represent filter criteria that can be used by the filter parameter. 

KeyDescriptionExample Filter
name
The name of the item. Utilizes the * character as a wildcard character. 


Code Block
languagepy
# Literally search for "MyTag"
{"name":"MyTag"}

# Searches for any names that contain "Tag" in their name
{"name":"*Tag*"}


dataType
Represents the data type on the tag. Valid values can be found on the  Tag  Properties page .


Code Block
languagepy
{"dataType":"Int4"}


valueSource
Represents how the node derives its value. Generally only used by nodes with a tagType of "AtomicTag". Valid values can be found on the Value Source description on the Tag Properties page


Code Block
languagepy
{"valueSource":"opc"}


tagType
The type of the node (tag, folder, UDT instance, etc). A list of possible types can be found on the Tag Properties page 


Code Block
languagepy
{"tagType":"AtomicTag"}


typeId
Represents the UDT type of the node. If the node is not a UDT definition, then the result will not contain this key. If value will be None. If the node is not a UDT definition, then this filter choice will not remove the value will be Noneelement. As such, this filter functions best when paired with a tagType filter with a value of UdtInstance.


Code Block
languagepy
{"typeId":"myUDT", "tagType":"UdtInstance"}


quality
Represents the quality on the node. While there are many types of quality codes, this function only recognizes "Bad" and "Good". More granular quality codes are ignored. 


Code Block
languagepy
{"quality":"Good"}


maxResults
Limits the amount of results that will be returned by the function. 


Code Block
languagepy
{"maxResults":10}




Panel
titleResults Object

The contents of each dictionary in the Results object varies based on the tagType of the node in question.

General Keys

By default all dictionaries contain the following:

KeyDescription
fullPath
A fully qualified tag path to the node, including the name of the node. 
hasChildren
A boolean representing if the node contains sub-nodes, such as folders and UDT definitions. Useful in cases where you need to recursively call the browse function. 
name
The name of the node. 
tagType
The type of the node. 


Tag Keys

If the node is a Tag ( tagType = AtomicTag ), then it will also contains the following keys:

KeyDescription
dataType
The data type of the tag.
valueSource
Represents how the tag derives its value. 
value
The last known qualified value on the tag. 


UDT Keys

Both UDT Instances and UDT Definitions add the following key:

KeyDescription
tagType

Represents the type the UDT is based off of. 

UDT Definitions will have a value of None . 




Panel
titleCode Examples


Code Block
languagepy
titleCode Snippet - Simple Browse
# This simple script will browse a given Tag path, in this case the root of the provider called default, and print the results.

results = system.tag.browse(path = '[default]', filter = {})
for result in results.getResults():
	print result



Panel


Code Block
languagepy
titleCode Snippet - Filtered Browse
# This simple script will browse a given Tag path, in this case the root of the provider called default, and print the results.
# It also is filtering out anything that is not Atomic Tag, like folders and UDT Instances.

results = system.tag.browse(path = '[default]', filter = {'tagType':'AtomicTag'})
for result in results.getResults():
	print result



Panel


Code Block
languagepy
titleCode Snippet - Wildcards with the Name Parameter
# Similar to the Filtered Browse above, except a wildcard character may be used when filtering on the name parameter
# The wildcard character ( the * character) represents any number of characters, including none.  

results = system.tag.browse(path = '[default]', filter = {'name':'*M*'})
for result in results.getResults():
	print result



Panel


Code Block
languagepy
titleCode Snippet - Simple Browse with Condition
# This simple script will browse a given Tag path, in this case the root of the Tag Provider called default, and print the results.
# After it browses, it finds all of the items that do not have children and prints only those.

results = system.tag.browse(path = '[default]', filter = {})
for result in results.getResults():
	if result['hasChildren'] == False:
		print result



Panel


Code Block
languagepy
titleCode Snippet - Recursive Browse
# This script has created a browseTags function which can be called with a Tag path and filter.
# The function will recursively call itself to find all items under that path by going into folders and UDT Instances.
# This example gives the initial path of '[default]', meaning it will find every item in the Tag Provider called default.

# Create the function
def browseTags(path, filter):
 
 	# First, browse for anything that can have children (Folders and UDTs, generally)
	results = system.tag.browse(path)
	for branch in results.getResults():	    
	    if branch['hasChildren']:
	        # If something has a child node, then call this function again so we can search deeper. 
	        # Include the filter, so newer instances of this call will have the same filter.
	        browseTags(branch['fullPath'], filter)

    
    # Call this function again at the current path, but apply the filter. 
	results = system.tag.browse(path, filter)
	for result in results.getResults():
		
		# Here's where you'd want to do something more useful. For now we print. 
		print result['fullPath']
         
# Call the function. Replace the filter with your own search criteria. 
browseTags('[default]', {'tagType':"UdtInstance"})




Panel
titleKeywords

system tag browse, tag.browse