hoch.png

Guides

API

To access the node's contents there is a small 'API' that you can use in the class.

Ports

Getting data from a data input:

self.input(index)

Setting value of data output:

self.set_output_val(index, val)

Executing an exec output:

self.exec_output(index)

Adding a new input:

self.create_new_input(type_: str, label: str, widget_name=None, widget_pos='under', pos=-1)
  • type_ refers to the input's type (exec or data)
  • label is the displayed name of the port
  • pos=-1 means the input will be appended at the end, everything else specifies the index at which the input will be inserted.
  • All widget related arguments are only important for data inputs:
  • widget_name holds the name of the input widget you want to use. If you don't want to use a widget, use None. Else, the widget name must be a string referring either to one of the std input widgets (see in NodeManager which are currently supported) or to a custom input widget you programmed.
  • widget_pos determines whether the input widget will be placed besides or under the the port

Adding a new output:

self.create_new_output(type_: str, label: str, pos=-1)

see above.

Deleting an input:

self.delete_input(index)

Deleting an output:

self.delete_output(index)

Access Ryven's stylesheet

self.get_default_stylesheet()

Variables

One of the best ways to make your nodes dynamic is to enable script variable dependencies. You can register methods that get called when the variable with the given name changes or gets created. To register such a method (or slot) in your node class, use

self.register_var_receiver(name, method)

To unregister a method, use

self.unregister_var_receiver(name)

Don't forget to unregister the old variable name when the referred name (given by the user through some widget probably) changes. Old connections don't get broken up when registering new ones, you can register as many connections as you want.

Accessing a script variable's value

self.get_var_val(name)

Setting a script variable's value

self.set_var_val(name, val)

This operation causes all registered methods (by any node) referring to the variable's name to be executed, in the order the connections were registered.

Logging

You can log mesasges to the script's logs via

self.log_message(message: str, target='global')

target can be global or error which addresses the global messages log or the error log.

A node can also request new logs using

self.new_log(title: str)

One node can hold mutliple personal logs.

To disable a log, use

mylog.remove()

All logs required by a node (via self.new_log()) get disabled automatically when this node is removed.

Debugging

If you are troubleshooting your nodes, you can turn debugging on. This will print a lot of information in the output window including the following error message

EXCEPTION IN <NodeInstance Name> NI: <exception>

whenever the execution of a node returned an error. That's a very useful feature. You can also quickly debug nodes by editing their source code directly in Ryven.

Package Path

If you want to access files you've put into your package folder (like pictures, but also python files etc.), you can access the path of the package of your node using

ni_pp(__file__)

in node files, and

widget_pp(__file__)

in widget files. Note, that this way you can create custom class hierarchies! As an example, take a look at the widgets of the matrix nodes in the linalg package, where I let them simply derive from one base class I've put in the package folder.