1

I want to shade smooth an object by its name ('Cube' for example). This is how I would do it but it doesnt work.

import bpy
bpy.ops.object['A'].shade_smooth()

Artichoke
  • 383
  • 3
  • 19
  • Hello ! I suggest you study a bit how operators work and are called with the python API, there are a few examples in the python templates available from the text editor in Blender – Gorgious Sep 11 '22 at 20:00

1 Answers1

1

Blender 3.2 + :

with bpy.context.temp_override(selected_editable_objects=[bpy.data.objects["A"]]):
    bpy.ops.object.shade_smooth()

Previous versions :

bpy.ops.object.shade_smooth({"selected_editable_objects": [bpy.data.objects["A"]]})

Gorgious
  • 30,723
  • 2
  • 44
  • 101