I want the screw object to rotate along the z-axis in 99 steps from 0 to 2*pi. For each step, the python can output an image and save in a folder.
The original position of the screw is like this:
I had expected the rendered image's position could be like this. It can only rotate along z-axis without the changing of the origin's position.
But after I ran my code, the position of the screw changed to this:
My code is:
def animationImages(path, num):
model = bpy.data.objects[0]
print(model)
model.rotation_mode = 'XYZ'
images_path = path
image_index = 1
for radi in np.linspace(0, 2*math.pi, num, endpoint = False):
model.rotation_euler = (0, 0, radi)
image_save_path = "{}/{}.png".format(images_path, image_index)
bpy.context.scene.render.filepath = image_save_path
bpy.ops.render.render(write_still=True, use_viewport=True)
image_index += 1
return
images_path = r'M:\RenderedModels\images'
num_images = 99
animationImages(images_path, num_images)
How can I write the code to get the expected result?