Fix #152992: Torus added in edit mode does not reuse existing materials on objects

Adding a torus to an object in edit mode does not reuse
the existing materials of the object but instead adds an
empty material slot for the torus. This is not consistent
behavior with adding other primitives. Resolve by copying
the active object's active material into the material slot of
the torus.

Pull Request: https://projects.blender.org/blender/blender/pulls/153099
This commit is contained in:
Tariq-Sulley 2026-01-21 04:25:17 +01:00 • committed by Tariq Sulley
parent 44cabb12ee
commit 943be0a28d

View file

@ -139,6 +139,10 @@ def object_data_add(context, obdata, operator=None, name=None):
if uv_act is not None:
uv_new.name = uv_act.name
# Copy the active object's active material into the primitive with no materials.
if len(obj_act.data.materials) > 0 and len(obdata.materials) == 0:
obdata.materials.append(obj_act.active_material)
bpy.ops.object.join() # join into the active.
if obdata:
bpy.data.meshes.remove(obdata)