Adding sublist to a list

Im trying to make a preset system for stored nodegroup inputs. It’s a list of all the inputs which contain name, factor and color. This is repeated over and over. Prior to bl5, we could store this easily at bpy.types.Scene.my_settings and simply add a new by doing scene.my_settings[“setting 01"] = [" name”, 0.244,[1,0.34,1,1]] etc etc

It basically looks like this per setting

my_dict = {
  'key1': 'some string storage',
  'key2': ['some', 'list', 'storage'],
  'key3': 5
}

I’m confused how would go around by using pointerproperty and perhaps another pointerproperty inside the other.

I basically want to give each dict set a name and store them as described earlier. Then either recall them by a uilist or a simply enumproperty.

I’ve searched Google for some hours now I don’t see any info or articles about not using the prior dicht approach.

EDIT

Here is a more expanded description with code examples

The real data looks like this, although that 1st input im going to change to a list of 2, just like i did here below

presetItem = {
            0: ('Compositing Nodetree', "Group"), 
            1: (0.8167939186096191, 'Area Top Dow', (0.052555330097675323, 0.42742449045181274, 0.7770897150039673, 1.0)), 
            2: (1.0, 'Enivornment', (0.0, 0.0, 0.0, 1.0)), 
            3: (1.0, 'Interior Light', (0.0, 0.0, 0.0, 1.0)), 
            4: (1.0, 'Light Front', (0.43450042605400085, 0.11602850258350372, 0.010636990889906883, 1.0)), 
            5: (1.0, 'Light Front R', (0.0, 0.0, 0.0, 1.0)), 
            6: (1.0, 'Light Rim Back L', (0.016390008851885796, 0.13765928149223328, 0.25482141971588135, 1.0)), 
            7: (3.0, 'Light Rim Front L', (0.6231090426445007, 0.17952165007591248, 0.03514079377055168, 1.0)), 
            8: (1.0, 'Lightgroup_004', (0.5569474697113037, 0.1895488053560257, 0.015195346437394619, 1.0)), 
            9: (0.045801520347595215, 'Mesh Light Back', (0.0, 0.0, 0.0, 1.0)), 
            10: (0.15267175436019897, 'Mesh Lights Front', (0.0, 0.0, 0.0, 1.0)), 
            11: (0.0, 'Top Lights Dow', (0.0, 0.0, 0.0, 1.0)), 12: (0.0, 'hedlights', (0.0, 0.0, 0.0, 1.0))
            }

im basically trying to create this, but than using pointerproperty and collectionproperty.


{
    "presetItem 01" : {
        0: ('Compositing Nodetree', "Group"), 
        1: (0.8167939186096191, 'Area Top Dow', (0.052555330097675323, 0.42742449045181274, 0.7770897150039673, 1.0)), 
        2: (1.0, 'Enivornment', (0.0, 0.0, 0.0, 1.0)), 
        3: (1.0, 'Interior Light', (0.0, 0.0, 0.0, 1.0)), 
        4: (1.0, 'Light Front', (0.43450042605400085, 0.11602850258350372, 0.010636990889906883, 1.0)), 
        5: (1.0, 'Light Front R', (0.0, 0.0, 0.0, 1.0)), 
        6: (1.0, 'Light Rim Back L', (0.016390008851885796, 0.13765928149223328, 0.25482141971588135, 1.0)), 
        7: (3.0, 'Light Rim Front L', (0.6231090426445007, 0.17952165007591248, 0.03514079377055168, 1.0)), 
        8: (1.0, 'Lightgroup_004', (0.5569474697113037, 0.1895488053560257, 0.015195346437394619, 1.0)), 
        9: (0.045801520347595215, 'Mesh Light Back', (0.0, 0.0, 0.0, 1.0)), 
        10: (0.15267175436019897, 'Mesh Lights Front', (0.0, 0.0, 0.0, 1.0)), 
        11: (0.0, 'Top Lights Dow', (0.0, 0.0, 0.0, 1.0)), 12: (0.0, 'hedlights', (0.0, 0.0, 0.0, 1.0))
    },
    "presetItem 02" : {
        0: ('Compositing Nodetree', "Group"), 
        1: (0.8167939186096191, 'Area Top Dow', (0.052555330097675323, 0.42742449045181274, 0.7770897150039673, 1.0)), 
        2: (1.0, 'Enivornment', (0.0, 0.0, 0.0, 1.0)), 
        3: (1.0, 'Interior Light', (0.0, 0.0, 0.0, 1.0)), 
        4: (1.0, 'Light Front', (0.43450042605400085, 0.11602850258350372, 0.010636990889906883, 1.0)), 
        5: (1.0, 'Light Front R', (0.0, 0.0, 0.0, 1.0)), 
        6: (1.0, 'Light Rim Back L', (0.016390008851885796, 0.13765928149223328, 0.25482141971588135, 1.0)), 
        7: (3.0, 'Light Rim Front L', (0.6231090426445007, 0.17952165007591248, 0.03514079377055168, 1.0)), 
        8: (1.0, 'Lightgroup_004', (0.5569474697113037, 0.1895488053560257, 0.015195346437394619, 1.0)), 
        9: (0.045801520347595215, 'Mesh Light Back', (0.0, 0.0, 0.0, 1.0)), 
        10: (0.15267175436019897, 'Mesh Lights Front', (0.0, 0.0, 0.0, 1.0)), 
        11: (0.0, 'Top Lights Dow', (0.0, 0.0, 0.0, 1.0)), 12: (0.0, 'hedlights', (0.0, 0.0, 0.0, 1.0))
    },
    "presetItem 03" : {
        0: ('Compositing Nodetree', "Group"), 
        1: (0.8167939186096191, 'Area Top Dow', (0.052555330097675323, 0.42742449045181274, 0.7770897150039673, 1.0)), 
        2: (1.0, 'Enivornment', (0.0, 0.0, 0.0, 1.0)), 
        3: (1.0, 'Interior Light', (0.0, 0.0, 0.0, 1.0)), 
        4: (1.0, 'Light Front', (0.43450042605400085, 0.11602850258350372, 0.010636990889906883, 1.0)), 
        5: (1.0, 'Light Front R', (0.0, 0.0, 0.0, 1.0)), 
        6: (1.0, 'Light Rim Back L', (0.016390008851885796, 0.13765928149223328, 0.25482141971588135, 1.0)), 
        7: (3.0, 'Light Rim Front L', (0.6231090426445007, 0.17952165007591248, 0.03514079377055168, 1.0)), 
        8: (1.0, 'Lightgroup_004', (0.5569474697113037, 0.1895488053560257, 0.015195346437394619, 1.0)), 
        9: (0.045801520347595215, 'Mesh Light Back', (0.0, 0.0, 0.0, 1.0)), 
        10: (0.15267175436019897, 'Mesh Lights Front', (0.0, 0.0, 0.0, 1.0)), 
        11: (0.0, 'Top Lights Dow', (0.0, 0.0, 0.0, 1.0)), 12: (0.0, 'hedlights', (0.0, 0.0, 0.0, 1.0))
    },
}

its a basically a preset system when using lightgroups, makes it super easy to make setups and then toggle between them

This is done by using the addon “Lighrgroup Helper”, which ive adjust so we can alter the color per light as well. The idea came from this scene, i got a hige list of lights and really liked some setups. So i started doing some code test. THe base parts like storre all inputs and restoring them works. Now i just need a nice panel or just an emum prop to show the presets

Okay, more progress. I got most of it working. Now need to tidy up the panel a bit more. Works like a champ and is very useful when doing relighting. Perhaps a bit niche, but it saves so much time!

That node group is also setup automatical. Ive added color as an extra

Hey @RomboutVersluijs ,

I have built an extension for this precise case. It works for all the Node Editors, and if it does not let me know and I will fix it!

Cheers,

juaum

1 Like

I’ll have a look at it. My case was only for this setup. But perhaps your version could come in handy. Thanks!

Edit

Ah nice, yours is much broader fornusae cases. Mine only takes this specific setup.

Ik going tonextend my version Abit with import/export options. Currently, it is added to bpy.types.NodeGroup meaning the presets are saved per nodegroup. This is nicer since each added nodegroupncan have different presets. But in case you loose the ng, you also loose the presets. I thought of adding it to a scene, so all ng added, het the same presets. Not sure why xh approach in should go with

NodeGroup storage gives flexibility but risks losing presets if the node group is deleted. Scene storage is safer and shared but less flexible per node group. A good balance is global defaults in Scene with optional NodeGroup overrides plus import/export for backup.

True!

But in my case or usage, a preset wouldn’t not work. Because the are very specific, they are per setup. You cant reuse them in others, unless they have the exact same light group setup. Thus saving a scene or global setup, would result in mainly errors, if you would want to apply it to others.

You could do this. By using a system which would allow you to apply each light setting and then manually let you choose a lightpathhroup from day an enum menu.