Possible to get Dict() sub dictionary reference (not copy) in JS?

tyler mazaika's icon

In Max, you can pass "get <foo>" to a [dict] where the value of <foo> is a dictionary. Output (2nd outlet) is:

<foo> dictionary u12345678

u12345678 is the name of the sub dictionary which can be very usefully used as the @name attribute of a dict.pack to modify the contents directly in the parent dict.

In JS, if you call mydict.get("<foo>") you are returned a Dict object, but this returned Dict does not have the same name when you query it's name property.

So, in JS is it possible to get the reference to the child dictionary rather than a Dict object?

FWIW I'm trying to do some scripted creation of [dict.pack] objects and set their @name, which is why I would like for this to work...

tyler mazaika's icon

@cycling74 folks... does anybody know if this is possible?

The workaround involves going from JS into max messages to a [dict] object and back to JS. It's cumbersome.

Trevor being Trevor's icon

Not sure if this helps, but in the past I have saved the child dictionary to a separate variable, made changes and then saved it back into the parent dictionary.

tyler mazaika's icon

Yeah, that's inefficient and precludes the use of the same child dictionary being modified from multiple places in the UI, among other things.