Search code examples
pythonpython-2.7dictionarymayaautodesk

how to store a maya nodes hierarchy into a python dictionary


Click here for view the example picture

I need to get the hierarchy Data or store it into a dictionary from the outliner panel from Maya in the right order, how can i archive this ? , im working in autodesk maya and only can be store into a dict for further used as a .json file.


Solution

  • Take a look at my answer from this question: How to store and then retrive parent-child dependency data (Maya MEL/Python script)

    Basically, there's a recursive function in there that starts from the top node and goes through the hierarchy storing everything into a dict.

    Once you have that dict, it should be very easy to spit out a json file.

    There's also some code for re-parenting everything.

    hope that helps!