I am trying to import an SVG file and because when using the bpy.ops.import_curve.svg() the imported file seems not correct, I would like to use the bpy.ops.wm.gpencil_import_svg(). When testing it from menu, SVG is imported correctly.

The issue is, that nothing happens when I use bpy.ops.wm.gpencil_import_svg from Python, the only thing I can see is that the operator writes {'FINISHED'} and nothing is inserted into the scene.

Also the bpy.context.view_layer.objects.selected is empty after the import. Below is the line I used for the import, I tried many combinations of the filepath/directory, but nothing seems to work. What am I doing wrong?

     bpy.ops.wm.gpencil_import_svg(filepath="/tmp/file.svg", scale=1)

1 Answer 1


OK, i have figured it out, based on the source code of the corresponding C code. One must provide the files array with list of filenames, together with the directory string, setting the path, filepath must also be provided but can be an empty string:

bpy.ops.wm.gpencil_import_svg(filepath="", directory="/path", files=[{"name":"filename.svg"}])

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .