Advertisement
Guest User

Untitled

a guest
Sep 5th, 2023
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. import bpy
  2. import math
  3.  
  4. # Set the path where you want to save the renders
  5. output_path = "D:\\Downloads\\renders\\"
  6.  
  7. # Set the name of your object in Blender
  8. object_name = "Cube"
  9.  
  10. # Set the rotation angles in degrees
  11. angles = [0, 22.5, 45, 67.5]
  12.  
  13. # Generate permutations of angles along x, y, and z axes
  14. permutations = [(x_angle, y_angle, z_angle) for x_angle in angles for y_angle in angles for z_angle in angles]
  15.  
  16. # Iterate over each permutation and render the object
  17. for i, (x_angle, y_angle, z_angle) in enumerate(permutations):
  18. # Clear existing objects and materials
  19. bpy.ops.object.select_all(action='DESELECT')
  20. bpy.ops.object.select_by_type(type='MESH')
  21. bpy.ops.object.delete()
  22.  
  23. # Import your object or create a new one if needed
  24. if object_name not in bpy.data.objects:
  25. bpy.ops.mesh.primitive_cube_add(size=2)
  26. obj = bpy.context.object
  27. obj.name = object_name
  28. else:
  29. obj = bpy.data.objects[object_name]
  30.  
  31. # Set the rotation of the object along x, y, and z axes
  32. obj.rotation_euler[0] = math.radians(x_angle)
  33. obj.rotation_euler[1] = math.radians(y_angle)
  34. obj.rotation_euler[2] = math.radians(z_angle)
  35.  
  36. # Set up rendering settings
  37. scene = bpy.context.scene
  38. scene.render.image_settings.file_format = 'PNG'
  39.  
  40. # Set output path and filename for each render image
  41. scene.render.filepath = f"{output_path}render_{i}.png"
  42.  
  43. # Render the image
  44. bpy.ops.render.render(write_still=True)
  45.  
  46. print("Renderings complete!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement