copy all freestyle linesets from active scene and paste them to all the other scenes

I am trying to get blender to sync up the freestyle linesets and their data in all scenes in my blend file.

Is it possible in python code to get blender to copy all of the line sets from my current scene and paste them in all the other scenes?

Yes. Line sets are just like other data properties in Blender, and copying them from one scene to another is a matter of looping over all line sets, and copying all relevant props of individual line sets.

Based on an add-on to copy render layers I did a proof-of-concept code below to copy and paste line sets between two scenes.

import bpy

excludes = ('__doc__', '__module__', '__slots__', 'bl_rna', 'rna_type')

linesetsFrom = bpy.data.scenes['Scene'].render.layers['RenderLayer'].freestyle_settings.linesets
linesetsTo = bpy.data.scenes['Scene.001'].render.layers['RenderLayer'].freestyle_settings.linesets

for name in linesetsFrom.keys():
    src = linesetsFrom[name]
    dest = linesetsTo.get(name)
    if dest is None:
        dest = linesetsTo.new(name)
    for attr in dir(dest):
        if attr not in excludes:
            print(attr)
            setattr(dest, attr, getattr(src, attr))


This did the trick!! Thank you :slight_smile:

Another question - how do you erase all linesets in the target scenes before pasting to them? I have this problem where the old linesets are being kept