RFE: Slicing of parGroups

Hey guys,

as you know I’m super happy with the parGroups implementation, props for that!
I’m already using it a great deal. In my current project I often have to assign new values to a few parameters in a parGroup while leaving the other pars in that same parGroup as is, so now I thought of a useful addon to my wishlist:

RFE: make the parGroup sliceable

Goal: to assign values to multiple (but not all) pars in a parGroup, in one call

Explanation: The parGroup is already an iterable tuple in TD. In normal Python, tuples can also be sliced.
If we could also slice a parGroup, we could for instance in a Constant TOP assign colorg and colorb color, while leaving colorr alone, all done in one call.
(perhaps the goal is best comparable to ‘swizzling’ in GLSL, which enables you to update multiple components of a vector in one call).

Example code how this would work:

>>> n = op("constant1")
>>> n.parGroup.color = (0.1,0.2,0.3)
>>> print(n.parGroup.color)
(0.1, 0.2, 0.3)
>>> n.parGroup.color[1:] = (0.5, 0.6)
>>> print(n.parGroup.color)
(0.1, 0.5, 0.6)
>>> print(n.parGroup.color[:2])
(0.1, 0.5)
3 Likes

Great suggestion. We’ll add it to the scope.

3 Likes

So this will be included in builds 2022.25710 and later.

One note:
What it returns will be a list of Par objects, not a list of floats.
To get what you need above, you can currently use slice syntax on eval() :

Example:

n.parGroup.color.eval()[:2]

Cheers

3 Likes

awesome @rob !

thanks so much for squeezing this in your to-do list. :raised_hands: