[SOLVED] Paste a variable with children

Hello, I noticed that exist an “Append variable to array” event but I didn’t find an event to do the same thing with a not-array variable. For example, I’d like to paste the children of the structure “A” variable to the “B” variable and possibly merge more structure variables (if the “B” variable is not empty, for example). Do you know a way to do this? Thank you.

Yes same happens to me, I think is not possible

Oh, that’s a pity, it would be handy.

You can ask for a feature like that

Oh, I noticed now the category. Thanks, I’ll try to ask for it!

Nice :+1::+1::+1::+1::+1::+1::+1::+1::+1::+1:

This seems to work for simple, one layer structures::

Before space was pressed:

And after space was pressed:

4 Likes

Good so the Foreach child is for arrays and structures then?

Oh, thank you very much, I’ll try it for sure! I never understood how the “for each child variable” events work.

Is there a way to paste an object variable into a scene variable?

I think there is an extension maybe can help

If you want to take the entire structure or substructure of an array or structure variable and paste it elsewhere via events.

Use the “json to variable” action to point it to your destination, rhen using the “globalvariabletonson” expression as the source data. With the array level or levels you want. All children of that level will be copied and recreate.d

There are expressions and actions for each rype of scene/object/global variable.

Thank you, but there’s a problem: your solution copies the structure/array but overwrites the target variable. Do you know a way to prevent that?

Not sure what you mean. If the variables have the same name of course they’d be overwritten.

Can you provide more context?

He means, if you have variable a = ab and b=c
now, doing that will cause b = ab, but he needs b = abc
Without c getting removed

Exactly, and of course if the variables a and b have a child with the same name the one in the b variable it will be overwrite.

Ahh. I’d just copy your structure to a child of your destination then.

If your variable is:
MyVariable (top level)
MyVariable.Item1
MyVariable.Item2

And you want to load another structure in while keeping Item1/Item2, load the JSON to a child
MyVariable.Load

That way you’ll have
MyVariable (top level)
MyVariable.Item1
MyVariable.Item2
MyVariable.Load (Substructure with your loaded data)

Ok, I solved it in this way:


Thank you all for your help!