Reference/Release Notes/3.4/Python API

Python API & Text Editor

Blender as a Python Module

Various changes have been made to improve support for running Blender as a Python module.

  • bpy.app.program_path defaults to an empty string which can be written to, allowing scripts to point to a Blender binary (f7a4ede79f).
  • The module is now built as a self contained Python-package "bpy" (81558783e4).
  • GPU rendering via (EEVEE / WorkBench) is now supported on Linux (3195a38120).

Additions

  • New GPU built-in shader enums that work for both 2D and 3D. The 2D and 3D versions are deprecated. (8cfca8e1bd)
  • New function bmesh_utils.bmesh_linked_uv_islands to access UV islands from a BMesh (de570dc87e).
  • File select dialogs will now call the update callbacks of the attached operator's directory, filename and filepath properties (48d7ff68f0). This will allow for much more interactive dialogs since, for example, operators can now present different options based on what file is currently selected.

Internal Mesh Format

The internal data structure for meshes has undergone significant changes, mainly by splitting up data to be stored in separate arrays. More information is available on the a design task. More mesh data is now accessible with the generic attribute system, accessible with Python as mesh.attributes[name]. The existing API to retrieve this data remains, but it will be slower. The new methods should be faster in most situations. The attributes may not exist, so they must be created first.

  • The "hidden" status of Mesh vertices, edges, and polygons is now stored in separate generic boolean attributes (2480b55f21).
    • The attribute names are .hide_vert, .hide_edge, and .hide_poly, and have BOOLEAN type.
  • Similarly, mesh selection has also been moved to generic attributes (rB12becbf0).
    • The attribute names are .select_vert, .select_edge, and .select_poly and have BOOLEAN type.
  • Mesh polygon material indices are now stored in a generic attribute (f1c0249f34).
    • The attribute name is material_index, with the INT type.
  • Sculpt face sets are stored in a generic attribute, now accessible with the Python API (rB060a5341).
    • The name is ".sculpt_face_set", with the INT type.
  • Internally, bevel weights are now stored optionally in separate arrays, though the attribute for accessing them remains unchanged (rB291c313f).
    • The use_customdata_vertex_bevel and use_customdata_edge_bevel properties have been replaced with operators for removing and adding the layers: MESH_OT_customdata_bevel_weight_{vertex,edge}_{add,clear}
  • Subdivision surface edge creases are now stored optionally in a separate array (rBa8a45428).
    • Meshes have a new edge_creases property used to access crease values separately from edges (which is faster).
    • The properties use_customdata_vertex_crease and use_customdata_edge_crease have been removed. They can be replaced by the API above or the MESH_OT_customdata_crease_{vertex,edge}_{add,clear} operators.


As an example, here the sculpt face sets are created if they don't exist.

if ".sculpt_face_set" not in mesh.attributes:
    face_sets = mesh.attributes.new(".sculpt_face_set", "INT", "FACE")
    face_sets.data[10] = 14

Breaking Changes

  • The unused node "add and link node" operator NODE_OT_add_and_link_node was removed (rB543ea415).
  • Unused operators MESH_OT_vertex_color_add, MESH_OT_vertex_color_remove, MESH_OT_sculpt_vertex_color_add, and MESH_OT_sculpt_vertex_color_remove were removed.
    • These operators can be replaced with the Mesh.vertex_colors.new() and .remove() functions (which are also deprecated), or with the attribute API (Mesh.attributes).
  • The Mesh properties use_customdata_vertex_bevel, use_customdata_edge_bevel, use_customdata_vertex_bevel, and use_customdata_edge_crease have been replaced with has_bevel_weight_edge, has_bevel_weight_vertex, has_crease_edge, and specific operators for adding and clearing the layer: MESH_OT_customdata_bevel_weight_{vertex/edge}_{clear/add}, and MESH_OT_customdata_crease_{vertex,edge}_{add,clear} (291c313f80, rBa8a45428).
  • Leak Size for Grease Pencil Fill tool has been removed. (bdbf24772a)
  • Added new methods to define how the lines are extender for Grease Pencil Fill tool (172b0ebe6a).
  • UV editing rounding mode, Snap to Pixels has been renamed Round to Pixels (b5115ed80f).
  • UV custom grid subdivisions can now be set for X and Y axis separately (a24fc6bbc1).
  • Geometry nodes do not use the NodeItem system anymore (rB837144b4).
    • Functions like nodeitems_utils.node_items_iter will not retrieve them anymore. Instead, one should iterate over node types directly.
  • Adding/removing/moving sockets on built-in node types is not possible anymore (rB52bd1981).

Render Engines Passes

Render results by default now only have a Combined pass, and render engines need to explicitly specify all other passes they produce. Blender queries the render engine's update_render_passes function and adds all render passes that the engine specifies using register_pass. (3411a96e74)

Previously, a number of built-in render passes were automatically added when the corresponding ViewLayer.use_pass_* property was enabled. If a render engine relied on this, the pass now needs to be explicitly added in update_render_passes.