← All ideas

Grease Pencil - Scene Output > FIle Format > SVG

There is currently an option to export an image sequence as JPG and PNG, is there an opportunity to export to SVG?

Currently I have to export each frame manually with File > Export > Grease Pencil as SVG 86c67f3fcc6af4e1a35810fb091b184fad1e5aaa_2_648x998.jpeg

100%

Development Status: Open

Upvote 10 Downvote 0
johnjoeparrot
18 Sep 2023

2 Comments

johnastudillomoreno

hi, i make this script with ChatGPT to export SVG from GP object, i the same way to do in Export windows:

import bpy import os

#Configuration output_dir = "D:\Proyectos\fondo" # Change this path to the directory where you want to save the SVG files gpencil_object_name = "Gpencil" # Change this to the name of your Grease Pencil object

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

#Reference to the Grease Pencil object gpencil = bpy.data.objects.get(gpencil_object_name)

if not gpencil: print("Grease Pencil object not found.") else: # Iterate over the frames of the animation frame_start = bpy.context.scene.frame_start frame_end = bpy.context.scene.frame_end

for frame in range(frame_start, frame_end + 1):
    bpy.context.scene.frame_set(frame)

    # Create the SVG file for each frame
    file_path = os.path.join(output_dir, f"frame_sinfondo_{frame:04d}.svg")
    bpy.ops.object.select_all(action='DESELECT')
    gpencil.select_set(True)
    bpy.context.view_layer.objects.active = gpencil

    # Export the current frame as SVG
    bpy.ops.object.convert(target='CURVE')
    bpy.ops.wm.gpencil_export_svg(filepath=file_path)

    # Convert the object back to Grease Pencil for the next frame
    bpy.ops.object.convert(target='GPENCIL')

    print(f"Exported {file_path}")

print("Export completed.")

johnjoeparrot Author

Are there any recommendations how to export each grease pencil frame as an SVG?