Specifying parameters in Blender macros

Blender macros differs from Blender operators – they don’t require a predefined “execute” function with constant actions. In macros actions are added after its registration using the “define” method.

After we have defined the macro class and registered it in the Blender Python API:

We can add actions to it with “define”. For example, to add “adding a default cube to the scene” action:

The “define” method returns a pointer to the operator to be executed, just like “self.layout.operator(…)” when defining the UI for user custom panels.

Through this pointer, we can pass the necessary parameters to the operator executed by the macro.

In order for the macro to add a cube to the scene at a point with coordinates X = 2.0, Y = 2.0, Z = 2.0, the required location can be set through the “properties”:

Executing our macro,

we will add a cube to the scene at a point with coordinates 2.0, 2.0, 2.0.

0 0 votes
Article Rating
Subscribe
Notify of
guest

2 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Iyad Ahmed
Iyad Ahmed
6 months ago

Amazing, I didn’t use macros much before