Using Python to run a preset for an add-on

I want to use Python to run an add-on

Something like:
import bpy
bpy.ops.export_mesh.paper_model()

I also want to use a preset for the add-on.
Something like:
bpy.ops.script.execute_preset(filepath="/Users/paulmmxx/Library/Application Support/Blender/3.3/scripts/presets/operator/export_mesh.paper_model/psg3.py", menu_idname="WM_MT_operator_presets")

Two or three questions (please)
How does Python cope with the space in the filepath (Application Support)? I could, of course, change the name of the folder, but Blender does not seem to have a problem with the space.

How do I call the add-on and use the preset at the same time? If I run one line at a time, it fails before I get to the second line.

Something like (but it does not work):

import bpy
bpy.ops.export_mesh.paper_model(filepath="/Users/paulmmxx/Library/Application Support/Blender/3.3/scripts/presets/operator/export_mesh.paper_model/psg3.py, menu_idname="WM_MT_operator_presets")

Or, is there a way to enter the code from the preset item by item, something like this:
import bpy
bpy.ops.export_mesh.paper_model(bpy.context.active_operator.page_size_preset = 'A3')

Looking at the code snippet, you seem to have missed a closing double quote at ..psg3.py". Probably that’s the only reasons it’s failing provided you copy pasted it here from your script.

And no, neither Blender nor Python should have any problem with spaces in the path as long as you enclose the entire path properly inside quotes.

1 Like