advice on duplicating bone chains

Hello all,

I’m working on one of my swiss-army scripts and I was hoping I could get some advice.

I want to be able to duplicate bone chains inside the script, and then run further modifications on them based on user input. By bone chain, I mean that if I start with the shoulder, it would duplicate all the hierarchy starting from the shoulder (shoulder, bicep, forearm / wrist, hand and fingers).

Now the question: how would you other python coders go about this? Currently I’ve thought up two methods:

  1. Create new bones using python, copying the variables from the old bones, and add them to the armature bone dictionary. This could work, although parenting might be tricky.
  2. Using the Window routines, duplicate the bones in the edit window by simulating key presses. This method is tricky in that you’ll have to predict how Blender will rename the duplicates (depends on bones already present), although the chain is preserved so you could just get the root and do a getAllChildren out of edit mode.

Right now, because I’m lazy I’m leaning towards method 2, but I’m interested in what others can suggest.

Thanks in advance.

Actually, 1 should actually be easier that 2. With 2, not you may very well run into issues with having some commands not responding to events passed to them.


mistake - deleted