Skip to content

Blender 4.5 LTS: Python API

Breaking Changes

gpu

  • gpu.types.GPUShader constructor is deprecated and will be removed in Blender 5.0. Use gpu.shader.create_from_info() instead. (9d06508837)
  • shader.program has been deprecated and will always return -1. (3562433ae7)
  • Using INT_TO_FLOAT inside GPUVertFormat.attr_add() has been deprecated. The attributes using these must be converted to float either before data transfert, or explicitly inside the shader. (91627b3d47)
  • Using non-4-bytes-aligned vertex formats has been deprecated. These attributes types will not be supported for 5.0. (57d9c2c098)
  • Using GPUBatch to draw wide lines or smooth lines with builtin shaders now requires using the POLYLINE shader variants. (3d8854b021)
  • Draw points with builtin shaders now requires using the POINT shader variants. (c56a855b9f)

Video Sequencer

  • The strips.new_effect() function's optional parameters seq1 and seq2 for specifying inputs to the effect strip are now called input1 and input2. (41781df1a6)

Render Paths

  • scene.render.frame_path() used to be infallible but can now fail if there are errors processing Path Templates in the render output path.

Shaders

  • The default distance for bump and displacement nodes change. Importers that create these nodes may need to set their values back to 1.0 for equivalent results. (bb6a88b95d)

Image & Movies

  • ImageFormatSettings now has a media_type member that needs to be set to an appropriate type before setting the actual file_format member. (92d5c2078e)
  • bpy.props

  • bpy.props.StringProperty with subtype set to DIR_PATH or FILE_PATH will warn when paths use a blend-file relative // prefix unless support is explicitly set, example: options={'PATH_SUPPORTS_BLEND_RELATIVE'}.

Additions

User Interface

  • KeyConfig.keymaps.find_match(keymap)

    Add a convenience function to find the matching key-map from another key-configuration.

    This avoids having to pass multiple arguments to the existing find method.

    (28126b83a5).

  • KeyMap.keymap_items.find_match(keymap, keymap_item)

    Add a method to support looking up key-map items from other key-maps.

    This allows an add-ons preferences to show the key-map editor for key-map items they define while maintaining the original key-map entries (used by "Reset to Default").

    Typically the find_match method should be called on key-maps from: context.window_manager.keyconfigs.user to lookup key-map items which the add-on created in: context.window_manager.keyconfigs.addon.

    (4a6d687d53).

  • GIZMO_GT_button_2d Gizmo type icon_value property

    Add a new icon_value property to the GIZMO_GT_button_2d Gizmo type to support using custom icons values. This allows for the use of user-defined icons (via custom preview collections), or generated icons like material or image previews.

    (ec149a919a)

    This property is also documented in a new Python Template, available from the Text Editor in Templates > Python > Gizmo Simple 2D.

    (bcb343c597)

Window Manager

Pipeline & I/O

  • Mesh.calc_smooth_groups(use_bitflags=False, use_boundary_vertices_for_bitflags=False)

    The Mesh API to compute smooth groups has been updated to also optionally take boundary vertices into account, and not only boundary edges.

    This seems to be the expected way to generate smooth groups by some other DCCs and game engines to correctly recompute normals from this data.

    See PR#105516 and PR#135248 for details.

    Committed as (00de07f752)

blf

  • Support for drawing into an image-buffer with the blf.bind_imbuf & blf.draw_buffer functions.

    with blf.bind_imbuf(font_id, imbuf):
        blf.draw_buffer(font_id, text)
    

    (c3e5a35ecd)

bpy.app

  • Support for bpy.app.build_options.image_webp (e94068e8d2)

imbuf

  • Support loading images from memory with imbuf.load_from_buffer (10e1aaf02c)

Sculpt

  • brush.asset_activate now performs a blocking load when used in background mode (898e6f3687).
  • sculpt.mask_by_color now takes in a location parameter to specify a region-space mouse position to execute the operator from a script (956a0fad80).

GeometrySet

  • A new GeometrySet API has been added that allows retrieving evaluated geometry data for objects in a much more direct way than before. (29fddf4710)
  • Documentation

Lights

There are new light controls. Exporters that do not natively supported these, can convert them like this:

if object.type == 'LIGHT':
    light = object.data

    energy = light.energy * math.pow(2.0, light.exposure)
    if not light.normalize:
        energy *= light.area(matrix_world=object.matrix_world)

    color = light.color
    if light.use_temperature:
        temperature_color = light.temperature_color
        color[0] *= temperature_color[0]
        color[1] *= temperature_color[1]
        color[2] *= temperature_color[2]

Nodes

  • New NodeSocket.is_inactive and NodeSocket.is_icon_visible accessors (fbb1204913).

Grease Pencil

See all Grease Pencil Python API changes.