Reference/Release Notes/4.1/Python API

Python API & Text Editor

Enum ID Properties

Support for enum items has been added to integer properties. 92cf9dd2f2

There is no support yet for editing enum items through the UI (see commit message for technical reasons).

Enum items can be added to an integer property using the id_properties_ui python method. The as_dict method can be used to retrieve a list of enum items of a property.

my_object["my_prop"] = 2
ui_data = my_object.id_properties_ui("my_prop")
ui_data.update(items=[
    ("TOMATOES", "Tomatoes", "Solanum lycopersicum"),
    ("CUCUMBERS", "Cucumbers", "Cucumis sativus"),
    ("RADISHES", "Radishes", "Raphanus raphanistrum"),
])
print(ui_data.as_dict())

Int properties with enum items are shown as a dropdown button in the UI.

Id property enums.png

Breaking Changes

Foreach

  • foreach_get and foreach_set have been optimized for cases where internal storage is 8, 16 or 64 bit. (PR #115761)
  • foreach_set now performs more accurate bounds checks, and raises an OverflowError in cases where the value was previously silently written incorrectly.

Light Probes

  • The Lightprobe type items have been renamed. It affects bpy.types.LightProbe.type, bpy.types.BlendDataProbes.new() and bpy.ops.object.lightprobe_add().
    • CUBEMAP -> SPHERE
    • PLANAR -> PLANE
    • GRID -> VOLUME
  • show_data has been deprecated. Use use_data_display instead.
  • Each LightProbe now has its own data_display_size property.

Mesh

  • Sculpt mask values are stored in a generic attribute (f2bcd73bd2).
    • The name is ".sculpt_mask", with the FLOAT type.
    • Accessing, adding, and removing masks is done in a simpler way:
      • The Mesh.vertex_paint_mask property returns the attribute directly, rather than a collection.
      • The Mesh.vertex_paint_mask_ensure() and Mesh.vertex_paint_mask_remove() functions add and remove the attribute.
  • The Mesh auto_smooth property has been replaced by a modifier node group asset (89e3ba4e25).
    • use_auto_smooth is removed. Face corner normals are now used automatically if there are mixed smooth vs. not smooth tags. Meshes now always use custom normals if they exist.
    • auto_smooth_angle is removed. Replaced by a modifier (or operator) controlling the "sharp_edge" attribute. This means the mesh itself (without an object) doesn't know anything about automatically smoothing by angle anymore.
    • create_normals_split, calc_normals_split, and free_normals_split are removed, and are replaced by the simpler Mesh.corner_normals collection property. Since it gives access to the normals cache, it is automatically updated when relevant data changes.
    • MeshLoop.normal is now a read-only property. Custom normals should be created by normals_split_custom_set or normals_split_custom_set_from_vertices.

Material

  • The displacement_method property has moved from cycles.properties.CyclesMaterialSettings to bpy.types.Material a001cf9f2b