Executing operators with parameters

When making your own custom operators, sometimes it is necessary to pass them certain values – execute operator with parameters.

The passed parameter must be defined as an operator property.

Let’s write a simple operator class to print a text value, passed to it through the parameter.

Define an operator class:

Add a string property with the “text” name:

And define an “execute” function to run when the operator is called:

This function prints the value of the “text” property, which we will pass as a parameter when calling an operator.

Register an operator:

Complete text:

After an operator registration we can call it with passing some text through the “text” parameter:

If we call our operator by pressing a button on the UI panel its parameter passes as follows: