06 April, 2020

Blender Python Tutorial: Updated Registration Method - bpy





In this video, we will be taking a look at the updated Registration Method for our script(s) and add-ons. 

The updated or new way to register classes is much more convenient than it was before. 









 The "Old Way"

In order to register any new classes we have to copy and paste "bpy.utils.register_class()".

Then paste (or type) the name of our new Class. We then had to copy/paste it again for the Unregister.
 


 The "New Way"

We no longer have to copy and paste a whole bunch of stuff. 

When adding any new classes, we just simply add the class name,
in to the "classes" list (make sure you separate each class with a comma).
As far as I am aware, it has no bearing on performance. Meaning, you can still use the old way to register your classes and they will still work. This "new way", is far better for our workflow (especially when you are creating lots of Operators, Panels and so on).

You can modify your old scripts (as we did in the video). If you would like to use the template script and follow along, you can find the script here.

I thought it would also be helpful to upload just the new registration snippet. You can download the template snippet here and just past it into your new Scripts. Remember to add the names of your Classes to the "Classes" Variable.

I hope you find this video helpful and as always thanks for reading!..

1 comment:

  1. Great tutorials , keep going ,
    can you make tutorial about append custom mesh object via menu with this setups :-
    0- in the top of menu
    1- add objects to the add menu.
    2- with sub-menu.
    3- and custom icons .
    4- and appending custom objects from the blend file .
    5- with a relative path , so I can attach a blend file with it.

    https://blender.community/api/storage/file/59/59d142eac020d60024a7fb76/1e/1e436c31482d4f9cbee97dd13695c739-l.jpg
    if any one can help or make tutorial about it , this will be nice thanks

    ReplyDelete