Home Technical Talk

(Workaround) Maya MEL: does it support key-value map / object / custom data structure?

polycounter lvl 6
Offline / Send Message
bitinn polycounter lvl 6
Basically I want to create a structure that can hold: $obj = { a:1, b:2, ... }, so you can query $obj["a"]

Alternatively, can I create a custom data struct where I can do $pair[] = [ {key:value}, {key:value} ], where each "pair" is key-value map.

Looking at the doc (and I have difficulty finding a spec for MEL), I only see array/vector etc., absolutely no data structure that can hold a "key:value".

(Yes I do need MEL as I am on Maya LT; I can workaround these problems just asking if I am missing something.)

Replies

  • Froyok
    Offline / Send Message
    Froyok greentooth
    As far I know Mel don't have any kind of "map" structure.
    The only suggestion I could give would be to use dags in the scene to emulate it. For example having groups with custom attribues. A group named with your "key" and a custom attribute being your "value". This way you can quickly iterate over the list of groups (for example with listRelatives and then query the attribute if the key is matched).
  • bitinn
    Offline / Send Message
    bitinn polycounter lvl 6
    Froyok said:
    As far I know Mel don't have any kind of "map" structure.
    The only suggestion I could give would be to use dags in the scene to emulate it. For example having groups with custom attribues. A group named with your "key" and a custom attribute being your "value". This way you can quickly iterate over the list of groups (for example with listRelatives and then query the attribute if the key is matched).
    Cheers, I was going with an array + search by values (basically O(n)), even though using on scene DAG troubles me this might be a better idea over a larger set of data.
  • throttlekitty
    This is out of my league, but this is the sort of thing you'd use Python for, yeah?

    edit, saw "LT" just as i submitted. nevermind.
Sign In or Register to comment.