Watches#

Watches help the user to keep an eye on something. They make interesting properties of nodes available for the user for quick access and reporting.

Any property of any node can be watched.

Watches can be created in two ways

  1. From the derived properties dock, by right clicking on a property and selecting “add watch”

  2. From the watch dock, by selecting a node and pressing “add watch to”

The watch itself is a piece of python code that is evaluated. During this evaluation the node that it is attached to is accessible as self. For convenience the standard options are shown as a list to pick from. As usual the scene itself is available as s

In the last example in the video the watch is set to np.random.rand(1) which will obtain a single random number from numpy each time it is evaluated.

Watches are saved with the model.

Tip:

It can be useful to display forces in a watch in tonnes instead of kN. To do so, divide the force by s.g (gravity). For example: self.tension / s.g

Difference between watches and limits#

Differences between watches and limits

  • Multiple watches can be defined on a single property

  • Watches do not have a limit

  • Watches do not contribute to the UC

Where are watches saved?#

  • Watches are stored in the Node they watch

  • But saved together with the scene (just like limits)

  • Watches defined in components get loaded with the component

    • But can be overridden in scene.

Scripting#

Watches are Watch objects and are stored as dictionary. The dictionary is a property of a node: node.watches.

To add a watch:

s['Point'].watches['new watch 1'] = Watch(evaluate = 'self.name',
      condition = '',
      decimals = 2)

To evaluate a watch use the run_watches method of a node. This will evaluate all the watches and return the execution result as text and values.

technical detail#

Managers may suppress saving of watches on the nodes they control by providing them with a _watches_by_manager dictionary. Watches that are already in that dictionary and have the same value will not be exported. This is used in HasSubScene.