Parenting Meshes to Bones

I am trying to create a NWN MDL import script with full animation support. I more or less have everything functioning except that I can’t figure out how to parent a mesh to a bone.

How do I make a bone the parent of a mesh?

Parent your object to the amature and a menu pops up:

Make Parent
Use Bone
Use Armature
Use Object

choose “use bone”.

This area of the python API needs to be reworked. With the current setup you don’t parent a mesh to an armature/bone structure. You need to assign the vertex points in the mesh to vertex_groups which in turn are linked to individual bones in the armature. NMesh has some vertex_grouping methods which help with this.

:expressionless: Whoops! Didn’t realize you meant with python…

Thanks for the replies. If I understand you correctly, I can still have the parts of the model span multiple meshes? Each mesh needs to be parented to the armature and needs a vertex_group containing all the vertices of the mesh, and a name corresponding to the bone I want to use? I’d prefer to keep the different parts of the object/character in seperate meshes ifl possible.

A semi-related question: Is there any way to parent an empty to a bone with the python interface?

Sorry for being rude with the slow response. I was away from the internet the last few days. :expressionless:

as far as i know, there is no way to do that – not from python nor the graphical interface.


as far as i know, there is no way to do that – not from python nor the graphical interface.[/quote]
You’re wrong, you can do it from the GUI. Just do a normal parent and it’s going to ask if you want to use a bone or the object.


great news - yesterday we needed this for one thing and the modeller was claiming it’s impossible, will tell him and try it again the next time

EDIT: argh, confusion … was obviously too tired yesterday when checking out this thread. our issue was that the parenting empties to bones does not work in the game engine, so quite unrelated (will try that yet, though) - sorry.


I’m interested on this. But I’m confused.
What should I do once the group is created and vertices assigned to it (using the functions you mentioned) ? How do I “link” this groups to individual bones ? Do you mean the “link” method ? I thought this kind of thing couldn’t be done yet.

In UI “linking” is done by giving the vertex group exatly the same name as the bone to link to has. so i’d think in python it is the same … but i’m not sure if UI does some secret magic.


In the UI, when you parent a mesh to an armature with Ctrl-P, you’re presented with a question wether you want to parent it to a Bone, the Armature or the Armature Object. For skeletal animation, you have to select “Armature”.
When I use armatureObject.makeParent() in python, it seems that that’s the equivalent of the 3rd option in the GUI, and the mesh won’t get deformed with the poses of the armature. Is there any way to do the parenting in the intended way with the Python API?

I’m continuing Bob Holcomb’s MD5 import script and have almost everything working, including vertex groups setup. When I do that parenting to the armature by hand via the GUI after the script has run (I select “Armature”, and “Don’t create vertex groups”, since the script created them already), the mesh deforms with the poses of the armature. If I do the parenting in python with makeParent(), it doesn’t.