vrQueryService

class vrQueryService

(Inherits vrBaseService)

The query service provides functions for advanced search with expressions.

The service allows queries for objects from different modules.

The search expression is based on Python syntax and must evaluate to a boolean (True or False). Each object is checked against that expression and added to the resulting list if it matches. In that expression you have access to predefined variables to access the object’s attributes:

name (query providing comparison operators and wildcard string matching)
metadata (vrdMetadata)
metadata.key (query on keys)
metadata.value (query on entry values )
metadata.set (query on set names)
metadata.type (query on entry value types)

metadata[“keystring”] (query on all values found for this key, keystring can be a wildcard expression)

node (vrdNode)
material (vrdMaterial)
light (vrdBaseLightNode)
camera (vrdCameraNode)
sceneplate (vrdSceneplateNode)

Two types of queries are provided: synchronous and asynchronous. Synchronous queries block the GUI while the query is evaluated. For large scenes, this may take too long. With asynchronous queries, the GUI continues to process events while the query is running. Note, both functions return after the query is finished. Asynchronous queries can be cancelled. The results of an asynchronous query are communicated in a signal after the query is complete.

Example to retrieve nodes from the Scenegraph that have tags matching a wildcard expression:

nodes = vrQueryService.sceneQuery("metadata['dash*'] == 'VRED-Tag'")
print("found nodes:", len(nodes))

Functions

vrQueryService.asyncCameraQuery(expression)

Starts a asynchronous query for cameras.

Parameters:expression (string) – A Python expression that returns a boolean value.
vrQueryService.asyncLightQuery(expression)

Starts a asynchronous query for lights.

Parameters:expression (string) – A Python expression that returns a boolean value.
vrQueryService.asyncMaterialQuery(expression)

Starts a asynchronous query for materials.

Parameters:expression (string) – A Python expression that returns a boolean value.
vrQueryService.asyncMetadataQuery(expression)

Starts a asynchronous query for metadata sets.

Parameters:expression (string) – A Python expression that returns a boolean value.
vrQueryService.asyncSceneplateQuery(expression)

Starts a asynchronous query for scene plates.

Parameters:expression (string) – A Python expression that returns a boolean value.
vrQueryService.asyncSceneQuery(expression)

Starts a asynchronous query for Scenegraph nodes.

Parameters:expression (string) – A Python expression that returns a boolean value.
vrQueryService.cameraQuery(expression)

Starts a synchronous query for cameras.

Parameters:expression (string) – A Python expression that returns a boolean value.
Returns:A list of all results of this query
Return type:List[vrdNode]
vrQueryService.cancelQuery()

Cancels an asynchronous query that is running.

vrQueryService.isCanceling()

Checks if an asynchronous query was canceled.

Returns:
Return type:bool
vrQueryService.isLiveSearchEnabled()

Gets if live search is enabled or not.

Returns:
Return type:bool
vrQueryService.isRunning()

Checks if an asynchronous query is running.

Returns:
Return type:bool
vrQueryService.lightQuery(expression)

Starts a synchronous query for lights.

Parameters:expression (string) – A Python expression that returns a boolean value.
Returns:A list of all results of this query.
Return type:List[vrdNode]
vrQueryService.materialQuery(expression)

Starts a synchronous query for materials.

Parameters:expression (string) – A Python expression that returns a boolean value.
Returns:A list of all results of this query. Items can be of type vrdMaterialNode for materials or vrdNode for groups.
Return type:List[vrdNode]
vrQueryService.metadataQuery(expression)

Starts a synchronous query for metadata sets.

Parameters:expression (string) – A Python expression that returns a boolean value.
Returns:A list of all results of this query
Return type:List[vrdMetadataSet]
vrQueryService.sceneplateQuery(expression)

Starts a synchronous query for scene plates.

Parameters:expression (string) – A Python expression that returns a boolean value.
Returns:A list of all results of this query
Return type:List[vrdNode]
vrQueryService.sceneQuery(expression)

Starts a synchronous query for Scenegraph nodes.

Parameters:expression (string) – A Python expression that returns a boolean value.
Returns:A list of all results of this query
Return type:List[vrdNode]
vrQueryService.setLiveSearchEnabled(value)

Sets whether live search is enabled or not.

Parameters:value (bool) – True if enabled, False otherwise.

Signals

vrQueryService.asyncCameraQueryFinished(success, results)

This signal is sent when an asynchronous query for cameras is finished.

Parameters:
  • success (bool) – True if the expression could be evaluated.
  • results (List[vrdNode]) – A list of all results of this query
vrQueryService.asyncCameraQueryStarted()

This signal is sent when an asynchronous query for cameras is started.

vrQueryService.asyncLightQueryFinished(success, results)

This signal is sent when an asynchronous query for lights is finished.

Parameters:
  • success (bool) – True if the expression could be evaluated.
  • results (List[vrdNode]) – A list of all results of this query
vrQueryService.asyncLightQueryStarted()

This signal is sent when an asynchronous query for lights is started.

vrQueryService.asyncMaterialQueryFinished(success, results)

This signal is sent when an asynchronous query for materials is finished.

Parameters:
  • success (bool) – True if the expression could be evaluated.
  • results (List[vrdNode]) – A list of all results of this query. Items can be of type vrdMaterialNode for materials or vrdNode for groups.
vrQueryService.asyncMaterialQueryStarted()

This signal is sent when an asynchronous query for materials is started.

vrQueryService.asyncMetadataQueryFinished(success, results)

This signal is sent when an asynchronous query for metadata is finished.

Parameters:
  • success (bool) – True if the expression could be evaluated.
  • results (List[vrdMetadataSet]) – A list of all results of this query
vrQueryService.asyncMetadataQueryStarted()

This signal is sent when an asynchronous query for metadata is started.

vrQueryService.asyncSceneplateQueryFinished(success, results)

This signal is sent when an asynchronous query for scene plates is finished.

Parameters:
  • success (bool) – True if the expression could be evaluated.
  • results (List[vrdNode]) – A list of all results of this query
vrQueryService.asyncSceneplateQueryStarted()

This signal is sent when an asynchronous query for scene plates is started.

vrQueryService.asyncSceneQueryFinished(success, results)

This signal is sent when an asynchronous query for Scenegraph nodes is finished.

Parameters:
  • success (bool) – True if the expression could be evaluated.
  • results (List[vrdNode]) – A list of all results of this query
vrQueryService.asyncSceneQueryStarted()

This signal is sent when an asynchronous query for Scenegraph nodes is started.