Page 1 of 1

Set bone layer from a Python script?

Posted: Sun Oct 21, 2007 7:19 pm
by jsgreenawalt
I'm trying to find a way to move a bone to a different bone layer via a python script. Does anyone know if this is possible? The docs don't seem to have anything on the subject.

Posted: Sun Oct 21, 2007 8:18 pm
by NielsBlender
jsgreenawalt,

I couldn't find it either...

I don't know your situation but I temporarily 'solved' it using a script that selects the 'right' bones for me in PoseMode, then I manually move the (selected-)bones to a different-layer...

Niels

ps.
To select the proper bones I added prefixes to the bonenames, like A_ for animation-bone, C_ for construction-bone, D_ for a deform-bone and of course a combination like AD_

Posted: Sun Oct 21, 2007 8:21 pm
by NielsBlender
jsgreenawalt,

Another method I came up with is using 'hidden_edit' to 'split-the-bones'.
Select the 'now-visible-bones', move them to layer 2, then 'unhide' the rest of the bones...

Niels

Posted: Sun Oct 21, 2007 8:35 pm
by jsgreenawalt
Thanks for looking Niels. Basically, I'm attempting to help Jeff Gran out with finishing up a blender version of his skeleton generator script http://www.garagegames.com/index.php?se ... w&qid=7792
The idea behind the script is that it can be used to generate skeletons that are compatible across different modeling packages.

The main problem that I've run up against is that Blender's bones are always pointing down the bone's local y-axis; a constraint that other modeling packages do not have (in fact, a bone's orientation is seemingly completely independent of it's local transform in other packages, similar to the way that a mesh can be rotated in edit mode by selecting all vertices and rotating without affecting the mesh object's tranform).

I've found a workaround (w/ Jeff's help) for the y-axis problem by creating two armatures; one armature that uses unconnected bones pointing off in random looking directions (to match the transforms of bones/nodes from other modeling packages), and another armature that's constructed in the normal way (but with incorrect transforms on the bones). I then have the "normal" rig drive the "export" rig through a series of copy loc/rot constraints. In order for the constraints to work properly, I need to have copies of the export rig bones w/ same default transforms in the "normal" armature to serve as constraint targets. The constraint target bones are prefixed with "CT_" and parented to the corresponding non-prefixed bones in the "normal" rig.

I've used this workaround to produce and release a blender model that's compatible with the animations from the default Torque game engine rig (produced in 3ds max). It can be found here, along with pictures of the two rigs and a brief description of how it's setup:
http://www.garagegames.com/index.php?se ... &qid=13546

In the above rig ("Orange Guy") I've manually moved the constraint target bones on the normal-looking armature to bone layer 16 in order to hide them and avoid confusing the end user. For Jeff Gran's skeleton generator script, it's desirable to have the script do the hiding of the generated constraint target bones.

Of course, none of this would be an issue if blender didn't have the y-axis bone limitation that I mentioned above
:(

I'll put in a feature request for Python access to bone layers.

Posted: Mon Oct 22, 2007 5:55 pm
by NielsBlender
jsgreenawalt,

I made AutoRig not so long ago, does 'exactly the same', except I wonder if Jeff Gran's can do other armatures than Torque..., since AutoRig can do 'a whatever you want build'...

Niels

ps.
http://niels.degooier.net/blender_scripts

ps2.
'exactly the same' -> there are a few differences, AutoRig lets you draw the needed primary bones where Jeff works with locators. I don't know if Jeff offers a userbuildArmature...

ps3.
I use AutoRig myself! :)

Posted: Mon Oct 22, 2007 7:50 pm
by jsgreenawalt
The scripts are similar in functionality, but the goal of Jeff's script is a little bit different, since he's going for compatibility between 3ds max, Maya, and Blender. The idea is that anyone who is using one of the three major modeling applications can have access to the same skeleton, and can create compatible animations for it w/o having to try to mess with getting armatures imported/exported to/from the various modeling apps (which is a total nightmare of incomplete exporter/importer support across all 3).

Posted: Tue Oct 23, 2007 6:20 pm
by NielsBlender
jsgreenawalt wrote:The scripts are similar in functionality
From what I read really fast on Jeff page -> I disagree...
jsgreenawalt wrote:The idea is that anyone who is using one of the three major modeling applications can have access to the same skeleton, and can create compatible animations for it w/o having to try to mess with getting armatures imported/exported to/from the various modeling apps (which is a total nightmare of incomplete exporter/importer support across all 3).
I don't know how to take this..., actions made with a 'same skeleton' having different bonesizes don't 'animate the same with the same action'... And the real problem seems to be the export/import between 'those 3'... Aren't people better helped with a skeleton-converter?

Hope this helps,
Niels

Posted: Tue Oct 23, 2007 8:19 pm
by jsgreenawalt
I made AutoRig not so long ago, does 'exactly the same',
jsgreenawalt wrote:
The scripts are similar in functionality


From what I read really fast on Jeff page -> I disagree...
I was just agreeing with what you had said earlier. It seems that you want to argue for some reason? You're only arguing with yourself. I'm not sure where this hostility is coming from.
I don't know how to take this..., actions made with a 'same skeleton' having different bonesizes don't 'animate the same with the same action'... And the real problem seems to be the export/import between 'those 3'... Aren't people better helped with a skeleton-converter?
The marker positions used to generate the skeleton can be stored so that the exact same skeleton (bone sizes and all) can be recreated in any of 3 different apps. Of course, if you want to write a version of your script for Maya and Max as well, I'm sure it could be made to do the same thing.

(edited for politeness)

Posted: Wed Oct 24, 2007 4:21 pm
by NielsBlender
jsgreenawalt wrote:I was just agreeing with what you had said earlier.
Then I think you missed the "'"-sign, the ps.-part, the part where I helped you and the part where I refer you to something I think you can use and not have to make especially for Blender, make once a .rig-file for Torque and you're done ;)
jsgreenawalt wrote:It seems that you want to argue for some reason? You're only arguing with yourself. I'm not sure where this hostility is coming from.
jsgreenawalt wrote:(edited for politeness)
Enough foolishness for me to end here, you must understand ;)

Hope this helps,
Niels

Posted: Wed Oct 24, 2007 4:45 pm
by jsgreenawalt
Then I think you missed the "'"-sign, the ps.-part, the part where I helped you and the part where I refer you to something I think you can use and not have to make especially for Blender, make once a .rig-file for Torque and you're done Wink
No, I didn't miss it. You sir, are seriously confused if you can re-read this conversation and think that what you've been saying makes any sense at all. Your script simply won't work for our purposes, and you have chosen apparently to take it as a personal affront to your ego. It appears that you've "taken over" this forum since my last visit here, and I can't say that the change is for the better.
Enough foolishness for me to end here, you must understand Wink
I do understand; I've wasted enough time here with this foolishness myself. :roll:

(go ahead and get in the last word so that this will end)

Posted: Wed Oct 24, 2007 5:11 pm
by NielsBlender
jsgreenawalt wrote:It appears that you've "taken over" this forum since my last visit here, and I can't say that the change is for the better.
Now I see your frustration, since I don't recognise myself in words like:
jsgreenawalt wrote:you have chosen apparently to take it as a personal affront to your ego.
Hope this helps,
Niels


ps.
How do words like 'Refer' and 'think you can use' are translated in 'You must take this', 'use it or else' ;)

Reminder: Play Nice!

Posted: Wed Oct 24, 2007 6:33 pm
by stiv
Just a reminder from your Friendly Moderator for everyone to play nice and stay on topic.

We put up with quite a bit here (see any of the Blender UI threads for examples!) but endless bickering is boring and uninformative. Remember that misunderstandings are often due to language difficulties, so take a deep breath and try not to say anything you would not say to your Mom.

Please limit any further posts in this thread to the subject: Set bone layer from a Python script?

This will not turn into another Yet Another Pointless Thread.