A pose-handling script

Another update. This one adds a number of features which relate to animation support.

  • Added a ‘Frames’ listbox. This allows quick selection and deletion of keyframes in the current animation. By right-clicking on a listbox line, the 3d view is sent to the specified frame. Using the ‘Batch’ toggle, this can be used to screen frames for batch save or to specify destination frames for batch load.

  • Added a menu of IK options to the bones listbox. Bones with IK solver constraints can be selected and IK settings can be specified for selected listbox bones.

  • Added batch import and export of poses for animation. These features can work with the frames listbox, as noted above. Batch handling can be activated for both save and load using the ‘Batch’ toggle on the poses listbox tab, or selected for either using the general options menus on the save and load tabs.

  • Added a ‘Tools’ menu to the bones listbox. This presents some basic functions to facilitate creation (or removal) of IK for selected bones. It can add bones, delete bones, re-parent bones, add IK solver constraints to selected bones, remove IK from selected bones, or change the IK target bone for selections. Re-parenting and re-targeting both point the inactive (yellow) selections to the active (red) selection. I have used these tools to quickly add IK, like that seen in the example nozzy posted, to my own armature. Hopefully these can be useful for others, as well.

The batch handling can work in a few different ways. The poses listbox, used with the batch option, offers the most flexibility, allowing multiple selections for load. If the file selector button or menu browser is used for batch loading, only one file can be selected, to load a numbered batch of files. Save exports files to a numbered batch in all cases, with length specified if the frames listbox is not being used for screening. If frames batch is not selected, both load and save will start from the current frame and run through the specified length. Using the frames listbox batch mode, loaded animations can be timed as desired and frames to be saved can be specified.

Sounds complicated. hopefully it isn’t so bad. :slight_smile: Some things may be complex enough to benefit from some sort of documentation now, perhaps. The three listboxes work together with various features, enabling a number of functions and tools which would have been rather more difficult otherwise. My thanks to nozzy for prompting the listbox creation. :slight_smile:

I do note a couple of things in need of development or revision. A series of IK-enabled poses, saved with the poseMatrix option then re-loaded with IK off, will not interpolate correctly. The frame interpolations for rotations and translations don’t seem to correspond as expected, leading to misalignments, even though the poseMatrix keyframes are correct. I’m trying to see if I can compensate for this in any way.

There also seem to be a couple of possible memory leaks. Blender registers increasing memory usage after a batch import or keyframe deletion. Assuming this is a scripting flaw, rather than some intrinsic limitation of Blender’s, I’ve been looking for a cause in my code, but I haven’t found anything yet. This has not caused any real problems in my tests, but others may have less RAM than I. If anyone has any problems or observations relating to this, please let me know.

With this update, the basic toolset I had originally envisioned is largely in place. Unless anyone has more requests or suggestions, future updates will probably be focused on revisions for efficiency or de-bugging.

As usual, please let me know if there are any problems, questions, or comments.

http://www.kuroyumes-developmentzone.com/~Cage/PoseLib14e.py

Another quick update. This adds a function to the bone roll menu on the options tab, allowing quick correction of bone roll angles. (Z axis for horizontal bones points up, for vertical bones points forward.) Also corrects a problem in the original post of 14e, in which bones could be re-parented to their descendants.

http://www.kuroyumes-developmentzone.com/~Cage/PoseLib14f5.py

This is really cool. I haven’t tested it thoroughly at all, but it works so far.

Each individual pose should be saved in its own .blend file, is that correct?

Anyway, I plan to mention this script in the book I’m writing on character animation with Blender, and probably include the script on the DVDROM, just to let you know. It’s really nice.

One thing. Is is possible to select bones based on their armature layer? I put all my posing bones on a layer together, and if I could select only them it would be handy.

T

Thanks, Bugman. :slight_smile: I’m glad to know that things are working for you. Please let me know if (or, more likely, when) you find any problems.

I hope you aren’t going to press right away with the book. I’m currently refining a few things, so the current version of this script isn’t quite where it should be, yet. Right now there are some conflicts between the various pose loading implementations, which need to be fixed.

You are correct - each frame/pose is saved to a separate .blend file. I have inherited a pose format from Mariano’s Blender Library and I am trying to remain consistent with BL formatting, rather than creating a multi-frame format of my own. In some ways the batch approach offers more flexibility for selecting some poses for import and not others. There are drawbacks, too. I should point out that the .blend pose files are simply .tx files with a different extension.

I will look into bone layer possibilities. I haven’t paid any attention to that functionality so far.

Great. As for when the stuff is due, I’m supposed to have everything ready, including the DVDROM contents, by the end of September. After that, it’s basically out of my hands. So let me know (you can pm me or mail me at blender.characters at gmail.com) when you have things the way you want them.

Hi Basil, not sure if its that usefull to ya but I just added headRadius and tailRadius properties to the bone, - so yo can adjust the size of envalope bones.

also made an example for turning that armature into a metaball and included in the docs. (Based off the script sombody posted earlier, but I could not find)

http://members.iinet.net.au/~cpbarton/ideasman/BPY_API/Metaball-module.html

Thanks, bugman2000. I’ll let you know. Hopefully I’ll be together by late September. :slight_smile: And I’ll keep posting updates here, in the meantime.

Cambo, those sound like useful additions, but I have no idea how to compile Blender from CVS, so I’ll have to wait for the next official release. Umm… BTW, have any bone layer handling functions been added to the API? I checked the 242 release of the epydocs, but I couldn’t find any reference to bone layers… but I’m sure I’ve read something about the functions having been added. It does seem like bone layer support would be a nice addition for the script.

This update mainly fixes a number of minor bugs.

http://www.kuroyumes-developmentzone.com/~Cage/PoseLib15b.py

Basil, thats next todo then (bone layers)
but Im having a bitof a break from python api stuff for a while, it will definetly be in next release.

Contrary to what Microsoft might think, there are alternatives :smiley:

http://www.firefox.web.com/ca/

… You dont’ work for MS do you ? :slight_smile:

Mike

*EDIT Obviously something’s out of whack with your system an alternate browser (may) be a quick fix.

Heh. Thanks, Mike. I didn’t test with FireFox. I save webpages to .mht archive format, using FireFox, but I understand it doesn’t read those as well as it writes them, so I tend to use IE when reading webpages saved to my hard drive. I should test 242a again, then. Total blue screen of death errors are harsh enough, however, to make me distrust a build altogether… :slight_smile:

And, woe for Microsoft, if they ever employed me. :slight_smile:

Blender crashes out with a consistent BSOD Windows error whenever I run 242a while Internet Explorer is open (a bit of a problem, since the Python API documentation is in html).

Now this strikes me as a bug that needs logging, if it can be replicated on anybody else’s machine… Pleased to say it can’t be on mine.

Ya, I sort of gave the “quck fix” answer. I only use I.E. for sites that won’t work with Opera or FireFox.

I’m running XP and have no problem with 2.42a + I.E. … + Opera + … multiple other applications all running :smiley:

Mike

I don’t know what to say about the 242a crash issue. Windows hates me. :slight_smile: I’m way behind the curve, however, using Windows ME on a six year old system, so I kind of expect things like this to plague me from time to time. :slight_smile:

Another update. This one fixes some bugs and adds some things. The new additions mainly focus on armature edit mode level options.

  • Fixed an error with deletion of selected keyframes. The last undeleted frame was ending up in the place of the first undeleted frame. It looks like it should be correct now.

  • Corrected automatic re-parenting of children when deleting a bone using the bones list tools option. This had been correct only for one level of parenting. Now it should be able to re-parent correctly all the way up the parenting chain.

  • Added protections against a potential crash bug with the IK removal option in the bones list tools menu.

  • Added use of .txt files to save preferred settings. This will store your gui layout, pose listbox folder, symmetry notation settings, and some pose load general options. This is available on the options tab as “Gui preference options”, and is set upon exit (otherwise it would always set the gui preferences to show the options tab). The settings file is saved to the Blender.Get(‘homedir’) directory.

  • Expanded the bone roll/head/tail text backup. It can now save roll, head, tail, parenting, and basic IK information. This can be used to restore settings to a current armature or to create a new armature from the text backup. It also includes an option to add missing bones to an armature when loading settings, which can be used to combine two dissimilar armatures. When creating an armature or adding new bones, there is an option to scale the added bones. This is on the options tab, as “Armature text backup options”.

  • Added four new edit mode tools to the bones list tools menu. These can scale all selected bones, translate all selected bones, flip all selected bones (as a group) over specified axes, and swap the head and tail positions for selected bones (effectively flipping the bone over itself).

I have also uploaded my companion script for Poser Python, which may be of use to anyone here who uses Poser. This script exports poses (single or batch) which are compatible with the Blender Pose Handler. The Poser script can also export a Poser figure as an armature text backup (which can be loaded into Blender using the new create armature feature), allowing quick and easy import of an armature which is compatible with the exported poses.

I’d like to say thank you to Cambo and Mike_S for their help with the IK problem.

I haven’t seen any occurence of the gui “ghosting” bug which nozzy mentioned some time ago. If anyone is encountering this, please let me know so I can try to stamp it out.

I seem to be having some difficulties really getting bone roll correction right. The current method is a bit of a hack, but it works better than anything else I’ve tried so far, including an adaptation of the approach seen in the Blender c source code. If anyone has any suggestions (or hints about correct math) regarding bone roll handling, please jump in and tell me. :slight_smile:

As always, please let me know if you have any problems, questions, or comments concerning this script.

Blender script:
http://www.kuroyumes-developmentzone.com/~Cage/PoseLib15e6b.py

Poser script:
http://www.kuroyumes-developmentzone.com/~Cage/poser2blender_v1.py

Windows ME

Oh. Maybe you may as well not log this one. I don’t even know if blue screening Windows ME counts as a bug at all.

Looking forward to checking out the script.

I’ve heard that, but honestly, ME has given me very little trouble over the years.

This is not as OT as it might seem. I understand that Curious Labs is giving away Poser 5 for free for the next few days. It’s worth grabbing a copy, for the walk designer alone. And it will work with my Poser companion script - as well as Cambo’s .bvh importer. :slight_smile:

http://www.contentparadise.com/us/user/free_poser_5_english_full_version_product_21989

Update to fix a couple of bugs and tweak a few things. this also adds a couple of additional functions to the bones list tools menu.

http://www.kuroyumes-developmentzone.com/~Cage/PoseLib15g2.py

This one adds Poser pose file export and more minor de-bugging. I’ve started zipping them.

http://www.kuroyumes-developmentzone.com/~Cage/PoseLib15g2c.zip

Holy options Batman ! :slight_smile:

Where’s the PDF manual ? :smiley:

I notice your “Bones” list seems to just dump out the bones in no particular order. Printing them in a hierarchical order would be nice. I started to work on that code awhile ago, but couldn’t figure out the recursive function setup to “walk” a tree structure. Maybe you or one of the other code wizards can whip up that code and post it. :slight_smile:

Since you seem to be writing the ultimate armature utility … :slight_smile: … a really nice utility would be a “bone search / select / highlight”. I’m actually trying to write it right now, and have just gotten to the point of probably you’re version .001 script :slight_smile:

I’m writing it because of the glaring (IMO) absence of a search function in the Outliner. Ideally I’d like to add that code right into Blender, but 1) I think Python is going to be A LOT easier, and 2) my build environment is broken right now :slight_smile:

I’m going to try to use the reg-expression modules in Python to match partial names and make a picklist an option. A picklist is kinda redundant, though, as it just replicates the Outliner.

If I get it working, I’ll post the code.

Mike

Can you describe the bone search function you want? What do you want to find and highlight? Bones in the 3d view? In another of the Blender windows? In the bones list in my script? I’m not quite sure what you’re requesting… (I may have said I’m a bit slow…) :slight_smile:

The Batman 66 reference brightens my day. Thanks. :slight_smile: I don’t know about ultimate armature utility. I like to think of it as evidence that I am a bit obsessive. :slight_smile:

And helpfile documentation of some sort is on my to do list…

BTW, the previously discussed crash problem with 242a hasn’t troubled me with one of the recent CVS builds from the JMS site. Hopefully it was a transitory problem.

I want to type in a partial bone name /wildcard (name completion would be cool) and have the bone highlighted in the 3d viewport and selected. I have that working now, only from a picklist (menu) instead of typing in the name.

Highlited/selected and ready for more operations in your bone list would be great.

Mike

Highlited/selected and ready for more operations in your bone list would be great.

I’ll see what I can do, but… remember that thread about editbone selection vs. pose bone selection? Edit mode selection doesn’t really cover all the angles, when used in pose mode. I think to really do this right, I’d want to use Cambo’s new option… but I hesitate to introduce a feature based on CVS code. I’m not sure how to screen out errors people might get from trying to use the function based on that code in the current formal release. I’ll see what I can work out.

I notice your “Bones” list seems to just dump out the bones in no particular order. Printing them in a hierarchical order would be nice. I started to work on that code awhile ago, but couldn’t figure out the recursive function setup to “walk” a tree structure. Maybe you or one of the other code wizards can whip up that code and post it. :slight_smile:

I may have added this already. :slight_smile: Actually, you can test it and verify that it does what I think. The bones list is normally sorted alphabetically (using list.sort()). I tried to work out a walk function, such as you suggest, but I kept getting stragglers, even after multiple passes through the function. Happily, the getAllChildren() function seems to return a hierarchical list. So I find the presumed root part and base a hierarchically-sorted list on getAllChildren. This option is currently the last one on the bones list select menu. Your preferred sort order can be saved with the gui prefs. Let me know if it works. I didn’t test extensively, with different armatures. It may not always do what I expect…