How to set Freestyle line set setting using python?
Blender 2.80

In order to activate the selection of edge marks you first need to access the Freestyle settings. These settings can be found in the view layer in Blender 2.80. Assuming your view layer is called "View Layer" you can access the settings using the following code:

freestyle_settings = bpy.context.scene.view_layers["View Layer"].freestyle_settings


Alternatively, if you always want to use the active view layer, then you can use the following instead:

freestyle_settings = bpy.context.window.view_layer.freestyle_settings


Next the line sets need to be accessed because the edge mark setting is configurable per line set. Assuming your line set is named "LineSet", you can access it the following way:

lineset = freestyle_settings.linesets["LineSet"]


Alternatively, if you always want to access the active line set, you can use the following instead:

lineset = freestyle_settings.linesets.active


Then you can enable the edge mark selection for the line set.

lineset.select_edge_mark = True




If you don't need access to the freestyle settings or the line set in other parts of your code you can also do this in a one-liner:

bpy.context.scene.view_layers["View Layer"].freestyle_settings.linesets["LineSet"].select_edge_mark = True


The alternative version when relying on the active view layer and line set looks like this:

bpy.context.window.view_layer.freestyle_settings.linesets.active.select_edge_mark = True




Blender 2.79

In order to activate the selection of edge marks you first need to access the Freestyle settings. These settings can be found in the render layer in Blender 2.79. Assuming your render layer is called "RenderLayer" you can access the settings using the following code:

freestyle_settings = bpy.context.scene.render.layers["RenderLayer"].freestyle_settings


Alternatively, if you always want to use the active render layer, then you can use the following instead:

freestyle_settings = bpy.context.scene.render.layers.active.freestyle_settings


The rest is exactly the same as in Blender 2.80.