17 August, 2020

Blender Python Tutorial: How to add an Enumerator to a Panel & Create a Property Group

 

 

In this video, we will be looking at adding an Enumerator and other Custom Properties onto a Panel. We will also be creating a Property Group which will contain a number of custom Properties we can define.

We will need a couple of things before we can get started. We will need a basic script that contains a Panel, operator and a registration section. You can use Blenders Templates to add a panel and operator (though if you want to follow along you can download the starting script here or you can download the Finished Script here).

We can then add our Property Group and fill it full of custom Properties. In this example we will be adding a String (so the user can enter text), a Float (so the user can enter a number value) and we will also be adding an Enumerator (dropdown). 

You can add more (or different) properties to suit your needs. 

 

 

 In this example we will be creating a String, Float and Enumerator Property.







 

After we have created the Custom Properties, we then need to display them on our Panel.


 In order for this to work we need to create a reference called 'mytool'. 

 

 

This reference is only possible thanks to the Pointer Property.


We need to register my_tool and define the Property Group that we want to use. We also need to delete the my_tool when it is no longer needed as shown below. 

 

 Like any other class, we need to add the Class Name to the Classes List.

 

 

Though in this case we need to add the MyProperties to the beginning of the list.

 

 



3 comments:

  1. In register/unregister function,you need to put "my_tool" opetations one tab back (not inside for loop), right?

    ReplyDelete