Blender 4.5 LTS: Python API¶
Breaking Changes¶
gpu¶
gpu.types.GPUShaderconstructor is deprecated and will be removed in Blender 5.0. Usegpu.shader.create_from_info()instead. (9d06508837)shader.programhas been deprecated and will always return-1. (3562433ae7)- Using
INT_TO_FLOATinsideGPUVertFormat.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
GPUBatchto draw wide lines or smooth lines with builtin shaders now requires using thePOLYLINEshader variants. (3d8854b021) - Draw points with builtin shaders now requires using the
POINTshader variants. (c56a855b9f)
Video Sequencer¶
- The
strips.new_effect()function's optional parametersseq1andseq2for specifying inputs to the effect strip are now calledinput1andinput2. (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¶
ImageFormatSettingsnow has amedia_typemember that needs to be set to an appropriate type before setting the actualfile_formatmember. (92d5c2078e)
-
bpy.props¶
bpy.props.StringPropertywith subtype set toDIR_PATHorFILE_PATHwill 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
findmethod.(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_matchmethod should be called on key-maps from:context.window_manager.keyconfigs.userto lookup key-map items which the add-on created in:context.window_manager.keyconfigs.addon.(4a6d687d53).
-
GIZMO_GT_button_2dGizmo typeicon_valuepropertyAdd a new
icon_valueproperty to theGIZMO_GT_button_2dGizmo 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.This property is also documented in a new Python Template, available from the Text Editor in Templates > Python > Gizmo Simple 2D.
Window Manager¶
- Expose NDOF motion (3D-mouse motion data) via Event.ndof_motion (776e2eb707)
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_bufferfunctions.
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_activatenow performs a blocking load when used in background mode (898e6f3687).sculpt.mask_by_colornow takes in alocationparameter to specify a region-space mouse position to execute the operator from a script (956a0fad80).
GeometrySet¶
- A new
GeometrySetAPI 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_inactiveandNodeSocket.is_icon_visibleaccessors (fbb1204913).
Grease Pencil¶
See all Grease Pencil Python API changes.