Skip to content

Blender 2.79: Python API

Breaking Changes

  • Switched default value of do_unlink parameter of bpy.data.xxx.remove() functions from False to True. (44b691dc65)

Data-block Pointer Properties

Custom properties can now store pointers to data-blocks like objects, materials, etc. For this the a PointerProperty with a datablock type can be created.

Forward Compatibility

Unfortunately, this new custom property type revealed a critical bug in current code, which crashes Blender on unknown property types. This bug has been fixed in 15189baa52 for the future, but it is impossible to fix this for existing releases. \<br \

This means that trying to load a .blend file using new data-block custom properties will crash on any version prior to 2.79.

For more technical details about the problem, see #51260.

Render Passes

Render passes are now identified exclusively by their name, the type property has been removed. The purpose of that change is to allow external rendering engines to produce arbitrary render passes and return them to Blender, rather than being limited to the 31 types of passes exposed by Blender before. (4cf7fc3b3a),)

Changes:

  • The properties type and debug_type have been removed from the RenderPass struct.
  • The function find_by_name has been added to the RenderPasses struct, and find_by_type has been deprecated.
  • SceneRenderLayer now supports custom properties, which allows render engines to add their own pass options.
  • RenderEngine has three new functions:
    • add_pass, which can be called by the render engine while rendering to add a render pass to the render result by providing its name, amount of channels, characters identifying the channels (like RGBA) and optionally which render layer it should be added to.
    • update_render_passes, which has to be implemented by render engines that use render passes. It's purpose is to inform Blender of which passes will be generated given the current options, which is does by calling register_pass for each one.
    • register_pass should be called by update_render_passes to inform Blender about a pass that will be generated by passing the name, channels and data type (used to determine the compositor output socket).
  • 31 pass names are reserved to represent the former 31 pass types. Render Engines may provide these passes, but should consider that they will be associated with the legacy pass types (for example, compositor node connections will be preserved).

Other New APIs

  • bpy.types.ID.make_local() to make a single ID block local. (592e9e9245)
  • Inserting entries in the right click menu (and retrieving data from the UI element that you clicked on the entry). Example in bpy.types.Menu docs. (d6963630d)
  • ID property arrays support the Python buffer protocol. This makes it possible to create and access those arrays much more efficiently. (73a9ff0d2d)