I’m still getting used to the 2.5x API, and I’ve got a simple question.
I’m writing a script to create a mesh object from Python data, and I’d like the Shading to be set to smooth when the object is added to the screen.
I have a Python list of verts and faces, which I run through these commands to build a new mesh in the scene:
mesh = bpy.data.meshes.new("Model") object = bpy.data.objects.new("Model", mesh) object.location = bpy.context.scene.cursor_location bpy.context.scene.objects.link(object) mesh.from_pydata(verts, , faces)
So far so good. But the mesh shows up with the default Flat shading, and I’d like it to be set to smooth. I know that the command (or a command, not sure if there are others) to set shading to smooth is bpy.ops.object.shade_smooth(). But I’m not sure where to put it in my code. I added it in at the end and it did nothing. Do I need to select my new object first? If so, how do I do that inside the script?