API Doc: improvements/fixes regarding new requirements for __init__/__del__

This commit is contained in:
Bastien Montagne
2024-11-19 12:59:42 +01:00
parent ee05765cc1
commit fcc1c89923
3 changed files with 27 additions and 7 deletions

View File

@@ -19,6 +19,8 @@ by returning ``{'RUNNING_MODAL'}``, initializing the modal loop.
Notice ``__init__()`` and ``__del__()`` are declared.
For other operator types they are not useful but for modal operators they will
be called before the :class:`Operator.invoke` and after the operator finishes.
Also see the
:ref:`class construction and destruction section <info_overview_class_construction_destruction>`
"""
import bpy
@@ -28,13 +30,13 @@ class ModalOperator(bpy.types.Operator):
bl_label = "Simple Modal Operator"
bl_options = {'REGISTER', 'UNDO'}
def __init__(self):
super().__init__()
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
print("Start")
def __del__(self):
super().__del__()
print("End")
super().__del__()
def execute(self, context):
context.object.location.x = self.value / 100.0

View File

@@ -17,14 +17,19 @@ class CustomRenderEngine(bpy.types.RenderEngine):
# Init is called whenever a new render engine instance is created. Multiple
# instances may exist at the same time, for example for a viewport and final
# render.
def __init__(self):
# Note the generic arguments signature, and the call to the parent class
# `__init__` methods, which are required for Blender to create the underlying
# `RenderEngine` data.
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.scene_data = None
self.draw_data = None
# When the render engine instance is destroy, this is called. Clean up any
# render engine data here, for example stopping running render threads.
def __del__(self):
pass
# Own delete code...
super().__del__()
# This is the method called by Blender for both final renders (F12) and
# small preview for materials, world and lights.