1
$\begingroup$

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()

$\endgroup$
1
  • $\begingroup$ 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 $\endgroup$
    – Gorgious
    Sep 11, 2022 at 20:00

1 Answer 1

1
$\begingroup$

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"]]})

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .