0

I would like to create a PropertyGroup Class with some of my own settings and then I would like to assign a settings instance to 4 different Environment Textures in my World.

This is what I would like to achieve for my Textures (example from Blender.org)


class MaterialSettings(bpy.types.PropertyGroup): my_int: bpy.props.IntProperty() my_float: bpy.props.FloatProperty() my_string: bpy.props.StringProperty()

bpy.utils.register_class(MaterialSettings)

bpy.types.Material.my_settings = bpy.props.PointerProperty(type=MaterialSettings)

test the new settings work

material = bpy.data.materials[0]

material.my_settings.my_int = 5 material.my_settings.my_float = 3.0 material.my_settings.my_string = "Foo"

I defined my class:

class Env_Settings(bpy.types.PropertyGroup):
    env_name: bpy.props.StringProperty()
    env_rot: bpy.props.FloatProperty(default=0)
    env_bright_cyc: bpy.props.FloatProperty(default=1)
    env_bright_eve: bpy.props.FloatProperty(default=1)

but I'm having trouble to understand where to hung it under. I can't put it under:

bpy.types.World.env_settings = bpy.props.PointerProperty(type=Env_Settings)

because then I can only instance it once. (All other instances will get the same values). So, how can I define 4 instances of my Settings Property for the four Environment Textures in my World node group? Thanks for any suggestion.

Steve
  • 446
  • 2
  • 8
  • You should use a collection property. I think this should help https://blender.stackexchange.com/a/24808/86891 and https://docs.blender.org/api/current/bpy.types.CollectionProperty.html – Gorgious May 24 '22 at 10:57
  • Fantastic, thank you! This is even better as not all of my settings are actually related to the environment texture itself. Initial test works, now I try to implement it in to my Add-On. – Steve May 24 '22 at 12:28

0 Answers0