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:

3.7 3 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments