As of May 31, 2023, we have updated our Code of Conduct.
2 of 4
corrected python comment
  • 25.3k
  • 2
  • 42
  • 100
import bpy
import bmesh

bpyscene = bpy.context.scene

# Create an empty mesh and the object.
mesh ='Basic_Sphere')
basic_sphere ="Basic_Sphere", mesh)

# Add the object into the scene. = basic_sphere = True

# Construct the bmesh sphere and assign it to the blender mesh.
bm =
bmesh.ops.create_uvsphere(bm, u_segments=32, v_segments=16, diameter=1)


In this case you need keyword arguments for all but the first, meaning you need to specify the argument name like u_segments=. The first argument is a positional argument, you only need to give the value bm. How do I know that? Because the Blender API Documentation is not very precise here, Blender told me in the Error message "bmesh operators expect a single BMesh positional argument, all other args must be keyword".

u_segments and v_segments control the initial subdivision of the mesh. diameter is the sphere size in local coordinate system (object transforation comes on top). matrix can be used if you want to shear, scale, rotate or move the sphere in one step. calc_uvs is about UV maps, but don't ask me what exactly.

  • 1.7k
  • 1
  • 8
  • 15