Maya transform presets using Python

Hi, I’m looking to store transform presets for a group of selected objects using Python inside of Maya. The only issue is that with the nodePreset command, it overwrites the previously stored file and I can’t see a way of storing a group of selected objects by using nodePreset. I was resorting to looping through each control and saving a preset but that makes over 100 .mel files in the 2020/presets folder which isn’t ideal. Originally I wanted to save the transform preset in the Attribute Editor under the object’s Transform Presets. Does anyone have an idea of how this might be accomplished?

If the nodes/hierarchy aren’t going to be changing, its probably easiest to just store the transform information into a json string.
You can use cmds.xform to query the transforms, and then just making a mapping of node_name : xform.
Then once you’ve got the json string you can attach that to any string attribute in the scene that you care to hide it on.

I believe there are already projects out there that have this kind of thing, usually for story character poses.
I believe Red9 has some kind of feature along these lines though I don’t know if they are using json or their own format for poses.

Great! Thanks Bob! I am not too proficient with JSON but I’ll take a look and see what I can figure out.