How to add a custom property on a Renderlayer ?

Hello blender users :slight_smile:

I’m trying to add a custom property to the renderlayers, but when adding it to the class bpy.types.SceneRenderLayer (which seems to be the right one, as reported by type(bpy.context.scene.layers.active)) I’ve this result when showing the property value on any renderlayer:

(<built-in function StringProperty>, {}) # Note: I used an empty StringProperty

Instead of the property value

Does someone know why this behavior is different a custom property creation on (for instance) a Scene ?
Is there a way to add a custom property to the renderlayers ?

Thanks :slight_smile:

Up :slight_smile:

Does someone knows how to add a property to a renderlayer, or at least to a sub/linked-component which makes the property dependant of the renderlayer ?

Thanks :wink:

Unfortunately, as far as I’m aware you can’t. The difference is that e.g. Scenes are ID datablocks, while SceneRenderLayers aren’t.

Two workarounds:

  1. Apply this patch: https://developer.blender.org/P374. It will allow you to add custom properties to SceneRenderLayers, but of course you need a custom Blender build…
  2. Rely on the uniqueness of SRL names: Add a CollectionProperty to the Scene with a custom type that contains the Name of the Layer and whatever you want to store. Then, when you want to access the data, loop through the items until you find the one that belongs to the SRL.

Thanks @lukasstockner97 for your answer :slight_smile:

  1. Interesting patch, I can’t wait to have it in Blender by default !
    However, it’s not a solution in my case, I’m doing that for an add-on that I’ll share - so a custom build would not solve the issue.

  2. That’s what I might do, but in that case the property is not included in every Renderlayer, so for every addition/removal of renderlayer I’ll need to detect it, create/remove a property on the fly, …
    Not handy at all, but at least, possible.

Thanks for your help :slight_smile: