I just noticed another bug in your code that is causing the behaviour you
mentioned.

# Store the data into the main
all_data[sel] = attr_data

This line is also just constantly replacing the top level key with the last
frames data. I think you need to be clear about what kind of data structure
you really want to end up with. Because the structure you listed in your
last email isn't even a valid python dictionary. Do you want to be able to
map the frame number to the data? Or do you just want a list of results?

Like this, where there is a mapping to each frame number?

{
    "|locator1": {
        "1": {
            "frame": "1",
            "rotateX": "1.0",
            "rotateY": "1.0",
            "rotateZ": "1.0",
            "translateX": "1.5",
            "translateY": "1.5",
            "translateZ": "1.5"
        },
        "2": {
            "frame": "2",
            "rotateX": "1.01",
            "rotateY": "1.01",
            "rotateZ": "1.01",
            "translateX": "1.51",
            "translateY": "1.51",
            "translateZ": "1.51"
        }
    }
}

Or like this, where its just a list of results?

{
    "|locator1": [
        {
            "frame": "1",
            "rotateX": "1.0",
            "rotateY": "1.0",
            "rotateZ": "1.0",
            "translateX": "1.5",
            "translateY": "1.5",
            "translateZ": "1.5"
        },
        {
            "frame": "2",
            "rotateX": "1.01",
            "rotateY": "1.01",
            "rotateZ": "1.01",
            "translateX": "1.51",
            "translateY": "1.51",
            "translateZ": "1.51"
        }
    ]
}

Pick one, and we can go from there to adjust your code. Basically you just
need to update that "all_data" assignment to either map the frame number to
your attr_data instance, or append it to a list.

Justin


On Tue, Dec 20, 2016 at 2:49 PM likage <[email protected]> wrote:

> Hi Justin, thanks for getting back..
>
> I tried your method, and I am still getting the same issue. The keyframes
> are still only being written once, same as the output that I have pasted in
> my first post.
>
> Actually, now I am doubting if using dictionaries are the right way to do
> so?
> Cause supposedly if my code does works, I assume the following is the
> output I will be seeing, though I am unsure if the recurring key names -
> 'frame', 'rotateX' etc will pose an issue later on or during the phase when
> such data are being inserted into the dictionary
>
> {
>     "|locator1": {
>         {
>             "frame": "1",
>             "rotateX": "1.0",
>             "rotateY": "1.0",
>             "rotateZ": "1.0",
>             "translateX": "1.5",
>             "translateY": "1.5",
>             "translateZ": "1.5"
>         },
>         {
>             "frame": "2",
>             "rotateX": "1.01",
>             "rotateY": "1.01",
>             "rotateZ": "1.01",
>             "translateX": "1.51",
>             "translateY": "1.51",
>             "translateZ": "1.51"
>         }
>     }
> }
>
> --
> 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/3b06a3cb-7fc2-4cf8-8d32-ee6e5e940a73%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/3b06a3cb-7fc2-4cf8-8d32-ee6e5e940a73%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/CAPGFgA1MGY3Ly6yNcuw%2Btb89eNsJf%2B4EPRP7OP5eGdXzi8FyAg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to