run multiple commands at once

hi, I’d like to ask if there is a way in python that i could execute multiple commands at once, without having to list each of them every time. For example, let’s say i have an example list of commands

bpy.ops.mesh.primitive_plane_add(radius=1)bpy.ops.transform.rotate(value=1, axis=(0, 2, 0))
bpy.ops.object.modifier_add(type=‘SOLIDIFY’)
bpy.context.object.modifiers[“Solidify”].thickness = 1

that i want to use them a few times through the script. Can I make a list including these commands, then call the “list” whenever i need it and run all the commands?

Yes, you are talking about a ‘function’.



# Define a function that adds a plane and a solidify modifier
def addSolidPlane():
  bpy.ops.mesh.primitive_plane_add(...)
  bpy.ops.object.modifier_add(type='SOLIDIFY')
  bpy.context.object.modifiers["Solidify"].thickness = 1

# Add a solid plane
addSolidPlane()

# Move the 3D cursor
....

# Add a second solid plane an the new location.
addSolidPlane()


… although the name “procedure” would be more appropriate here, since the the function doesn’t return anything (nor does it have parameters)

Thanks a lot, exactly what i was looking for