File size: 1,550 Bytes
2edc208
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import bpy
import os

# Set output directory
output_dir = "blender/materials/plys"  # Change this!

# Ensure the output directory exists
if not os.path.exists(output_dir):
    os.makedirs(output_dir)

# Set the frame range
start_frame = 1
end_frame = bpy.context.scene.frame_end

# Name of the object to export
object_names = ["materials", "materials.001", "materials.002", "materials.003", "materials.004", "materials.005", "materials.006", "materials.007", "materials.008", "materials.009", "materials.010", "materials.011"]

# Deselect everything
bpy.ops.object.select_all(action='DESELECT')

# Ensure it is selected and active
for name in object_names:
    obj = bpy.data.objects[name]
    obj.select_set(True)
    bpy.context.view_layer.objects.active = obj

# Loop through each frame
for frame in range(start_frame, end_frame + 1):
    bpy.context.scene.frame_set(frame)
    bpy.context.view_layer.update()  # Ensure simulation is evaluated

    # Export to .obj
    filename = f"{(frame - 1):05d}.ply"
    filepath = os.path.join(output_dir, filename)

    bpy.ops.wm.ply_export(
        filepath=filepath,
        apply_modifiers=True,
        export_selected_objects=True,
        export_normals=True,
        export_uv=True,
        export_colors='NONE',        # options: 'NONE', 'SRGB', 'LINEAR'
        export_attributes=False,
        export_triangulated_mesh=False,
        ascii_format=True,          # Set to False for binary PLY
        forward_axis='Y',
        up_axis='Z'
    )

    print(f"Exported frame {frame} to {filepath}")