I’m new to the 2.5 implementation of Python so I’m probably not quite doing things correctly, but a script I’m working on creates objects based on an armature and names them based on the bone names, but using a prefix. The prefix can be changed very simply. The script then makes the objects rigid body and links them together with rigid body joints to match the structure of the armature.
It took me a while to get my head around the concept of operators and how they work so I’ll outline my understanding of them… or possibly my mis-understanding of them.
An operator can be called in many ways, menu, button, script, keyboard shortcut, etc. I use a button in the Tools area of the 3d view. I think that these areas can only display object properties and buttons to call operators.
After the operator is called, it performs it’s actions, which can include drawing a ui in the Operator area of the 3d view. This ui can display properties of the operator such as values, booleans, etc. They can then be changed by the user. As soon as the value is changed, that operator runs again with the new values (such as a different prefix ;)). All uis can display properties, but I believe that the operator doesn’t exist before it is run and so it’s properties are not available to be displayed before it is actually run. I may well be mistaken about this.
For example, the translate operator (G key) can not be told how far to move an object before it is actually running. However, after it has finished, the properties of the translate operator will show in the operator area of the 3d view and can be changed. When a new value is set, the operation is undone and the operator is called again, but with the new values.
I have placed my script at http://www.paste all.org/16031 for you to look at, take apart and try out. You need to take the space out of the url. See http://blenderartists.org/forum/showthread.php?p=1704691
It is a very early alpha right now so should be used with caution, but actually does something so at least I can call it an alpha release.
Place the script in a text window of Blender and run the script. When you refresh the tools area of the 3d view by scrolling it or maybe just a mouse-over, the ui for the script will appear. I have yet to find a workaround to make the tools area auto-refresh. The options available will change depending on the current selected object and if an armature is selected, the Create button will appear. Hit it and the rigid body structure will be created and another panel will appear in the operator area of the 3d view. It is this panel that displays the operator properties such as prefix, box width, etc. Changing them will change the result of the script. I just had an “oh wow” moment when I tried the script on a full body rig and could change the sizes of all created boxes in real time. Very powerful.
Because the entire operator is run when it is called, I found that it was running quite slowly due to the constant creation and removal of the boxes. In order to avoid the creation of all boxes from scratch, I implemented a branch in the operator that calls the create_box or the reshape_box function depending on whether a box with the required name already exists. I believe this vastly increased the operation speed of the operator.
This is probably a very poorly written script and is probably too complex to demonstrate a solution very clearly, but might provide you with some insight and inspiration.
I’d appreciate it if you could let me know of any bugs that occur or suggestions that you might have.
Edit: The link to a .blend file that I am using to develop this script (as suggested below by PKHG) is https://sites.google.com/site/funkywyrm/Home/FunkyRagmo_254_5.blend