import bpy
# Set the rendering resolution
bpy.context.scene.render.resolution_x = 1920
bpy.context.scene.render.resolution_y = 1080
# Set the output file path
bpy.context.scene.render.filepath = "output.mp4"
# Create a new scene
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete()
# Add a new icosphere to the scene
bpy.ops.mesh.primitive_ico_sphere_add()
# Select the icosphere
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_all(action='DESELECT')
bpy.context.view_layer.objects.active = bpy.context.view_layer.objects[-1]
bpy.context.view_layer.objects.active.select_set(True)
# Enter Edit mode
bpy.ops.object.mode_set(mode='EDIT')
# Extrude and scale the icosphere to create the basic shape of the UFO
bpy.ops.mesh.extrude_region_move(TRANSFORM_OT_translate={"value": (0, 0, 0.5)})
bpy.ops.transform.resize(value=(1.5, 1.5, 1))
# Add a loop cut to create a panel on the top of the UFO
bpy.ops.mesh.loop_cut_slide(MESH_OT_loopcut={"number_cuts": 1, "smoothness": 0, "falloff": 'INVERSE_SQUARE', "edge_index": 4, "mesh_select_mode_init": (True, False, False)})
# Extrude and scale the panel to create a cockpit
bpy.ops.mesh.extrude_region_move(TRANSFORM_OT_translate={"value": (0, 0, 0.5)})
bpy.ops.transform.resize(value=(1, 0.5, 1))
# Add a new empty for the UFO to rotate around
bpy.ops.object.empty_add(type='PLAIN_AXES')
# Set the keyframes for the UFO's rotation
bpy.context.view_layer.objects.active.rotation_euler[2] = 0
bpy.context.view_layer.objects.active.keyframe_insert(data_path="rotation_euler", index=2)
bpy.context.view_layer.objects.active.rotation_euler[2] = 3.14159
bpy.context.view_layer.objects.active.keyframe_insert(data_path="rotation_euler", index=2)
# Set the frame rate and duration of the animation
bpy.context.scene.render.fps = 24
bpy.context.scene.frame_end = 48
# Render the animation
bpy.ops.render.render(animation=True)
Traceback (most recent call last):
File "\Text", line 32, in <module>
File "C:\Program Files\Blender Foundation\Blender 3.1\3.1\scripts\modules\bpy\ops.py", line 132, in __call__
ret = _op_call(self.idname_py(), None, kw)
AttributeError: Calling operator "bpy.ops.mesh.loop_cut_slide" error, could not be found
Error: Python script failed, check the message in the system console
I dont think my version is out of date, and I imported bpy