On Tue, Dec 20, 2016 at 6:33 PM likage <[email protected]> wrote:
>
>
> This works for me too.. It is just that it never occurs to me of using
> '1', 2' etc as the key for I am thinking it in terms of using the object's
> name to store the data..
> Need more practice with dictionary
>
The thing is that the key of a dictionary needs to be a non-mutable type,
which can be reliably hashed and not change after it becomes a key. A
dictionary cannot be a key to another dictionary because its content can
change. So if you want to be able to map your time-based results within a
selected path, then you have to use some other key. I just chose the time
as each key since its the variable that is different between each loop.
You can try changing your function to something like this:
def export_keyframe(sel):
...
all_data[sel] = {} # init empty time results
for time in range(start_frame , (end_frame + 1)):
attr_data = {}
cmds.currentTime(time)
# Get the value in each attribute
attr_data['frame'] = str(time)
for attribute in attributes:
attr_value = cmds.getAttr( sel + '.' + attribute)
# Assign the value into the dict
attr_data[attribute] = str(attr_value)
# Store the data into the main
all_data[sel][time] = attr_data # assign using time key
...
Justin
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/1cb4c70e-74ab-4af2-a149-129c7f0f77f9%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/1cb4c70e-74ab-4af2-a149-129c7f0f77f9%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3nt1EBxcHdj6Dd9KsEqMzBxwqu_EFDmKt2kvwmouCJzw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.