HeyVern's scripts and tools - (focus on bones)

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Fahim, Distinct Sun, Víctor Paredes, erey, Belgarath, slowtiger

Post Reply
User avatar
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

HeyVern's scripts and tools - (focus on bones)

Post by heyvern » Tue Jan 30, 2007 7:50 am

NEW! Save and Load bone Animation!

Updated: June 20, 2008
- Version 1.0. Fixed a few things for v7. Interpolation is now saved. Can import directly to an action. Includes icons when used as buttons (for Debut. Debut has no menu scripts).


There is a folder called menu_or_button_scripts.

Either place these scripts in the scripts/menu folder of your Anime Studio Pro installation or put them in your scripts/tool folder.


Then you need to edit your _tool_list.txt by adding this line of text to the bottom or your vector button listing as shown here:

Code: Select all

group Bone
color	204 220 232 255
tool	lm_select_bone		B
tool	lm_translate_bone	Y
tool	lm_scale_bone		S
tool	lm_rotate_bone		R
tool	lm_add_bone			A
tool	lm_reparent_bone	P
tool	lm_bone_strength	...
tool	lm_manipulate_bones	Z
tool	lm_bind_layer		...
tool	lm_bind_points		I
tool	lm_offset_bone		...

button	hv_save_bone_animation   ...
button	hv_load_bone_animation   ...

Oh good grief it's so freaking EASY! I don't even need to explain it.

There are two test files in the zip archive. One is "A" and one is "B".

Open the "A" file in AS. Make sure you select the top layer which is a bone layer. You must select a bone layer to use these scripts. Then select the save bone animation script; either the button or from the scripts/menu.

A window pops up that is pretty self explanatory. You can set the frame range of the saved animation.

Hit okay, name and save the file to your hard drive. There is no custom file format so you can save with the ".txt" extension. I may add a custom extension but it hardly seems necessary. Now close the "A" file.

Open the "B" file and run the load bone animation script.

Remember you must select a bone layer.

This has more "stuff". Choose the attributes of the bones animation channels you want to copy. Also there is a check box for "overlay" that will leave any keys already in place alone.

You can experiment with the sample files to see how the different settings effect the file diffferently. For instance there are no constraints or bone offset in the "B" file. When you load the animation file you saved and check the bone offset attribute that gets applied.

The only way to copy bone animation from the file is if the bones from the file you are importing into has the same named bones as the original you saved from. All other extra bones are ignored.

Notice in the "B" file there are a bunch of extra bones. When loading the animation files these bones are left alone. If you delete the "head" bone for instance the animation still loads. It just ignores the missing head bone.


NEW! Select all keyed bones

Updated: Dec 8, 2008



Installation Instructions:

Download and unzip directly into your scripts/tool folder. Edit the _tool_list.txt file and add the name of this script as a button:

Code: Select all

button	hv_select_keyed_bones	...
If you don't want to use it as a button and you have AS Pro, install in the scripts/menu folder.


Another one of those "this is driving me CRAZY" scripts created out of frustration in in 15 minutes. I always have to figure out which bones have keys and which don't so I can copy keys only for the bones that HAVE keys from one frame to the next.

Very simple to use. With a bone layer selected click this button on any frame in the time line (other than zero). Any and all bones that have translation, rotation or scale keys will be selected. Then it is an easy matter to just select the keys of the selected bones and copy or delete or move them.

Planned Additions:

I would like to add to "filter" different bone channels. So you can select all bones on a frame with only rotation keys, or just translation keys etc. Not sure exactly how to implement this but a pop up with check boxes might be a way to go, or if possible holding down a modifier key. Have never tried that with a button so I'm not sure if it works or not.

Another option would be to have multiple buttons for each channel. Don't like that one much. And yet ANOTHER option would be to make this a tool instead of a button with check boxes for the tool and then you just click on the screen to select. Seems like it breaks the flow if you have to switch tools though.


NEW! Copy Paste Bones!!!!!!!!!!!

Updated: July 12, 2008




Download the script and place into your scripts/tool folder. Edit the _tool_list.txt file and add the name of this script as a button. Other wise if you don't want to use it as a button and you have AS Pro, install in the scripts/menu folder


Pretty simple. Select the bones you want to copy. Set the percentage of scale. Check the box if you want to flip the bones left to right. Optionally check the "Copy to parent" check box if this is a child layer of a bone layer and you want to copy bones to the parent layer.

When copied to the same layer the bones are "offset" and "_copy" is appended to the name. However if you copy the SAME bones you will end up with a duplicate set with the same names. It will still work fine it just might be confusing to tell them apart. I reccomend my bone renamer script to keep the names unique after copying. It's up to you.

When copying bones all the constraints (except dynamics) are copied and applied. If the bones copied have control parents that are ALSO being copied the constraints are changed to point to the new copied bones.

If you copy bones and the constraint target is NOT copied the copied bones constraint target will be the same as the originals.

The scale function is FANTASTIC BABY! Set the scale and the bones are reduced or enlarged, including offset!!!!

I'm very happy with this script. it makes copying complex joint rigs a total breeze.

Find them for me. It's working pretty good for me.

NEW! Flip Points With Bone Binding button script

Updated: June 25, 2008


Place this script in the scripts/tool folder of your Anime Studio Pro application directory.


Then you need to edit your _tool_list.txt by adding this line of text to the bottom or your vector button listing as shown here:

Code: Select all

button	lm_smooth			M
button	lm_peak				P
button	lm_flip_points_h	...
button	lm_flip_points_v	...
button	hv_flip_points_h	...
I haven't created an icon for it so... you'll just have to make do for now. ;)


This is intended for use with the Copy Flip Bones and Bone Renamer scripts below this one. It is very simple.


You have an arm vector layer. You have bound points to different bones in the the parent bone layer. Now you want to duplicate the arm for the other side but you don't want to go through the trouble of binding all the points on the opposite bones.

First make sure you have IDENTICALLY NAMED BONES in your bone layer. They must be exact copies with extensions EXACTLY like this:



etc etc. The names must use _right and _left or the script won't do its magic. The flipper and renamer scripts make simple work of that task. Very easy.

Once the bones are setup simply duplicate your example arm layer, select all of the points and click the "flp horizontal" button I created for you.

The points will flip... but they aren't in the precise location (I'm working on this I promise).

All you do now is using the Standard AS translation tool (not fazek's if you have his tools installed) change the value in the x translation box so it is the opposite of what ever is there.

If the grouped points x position is say -1.346 remove the minus sign and the points will "flip" to the other side.

This flipping is of course based on the origin point of the layer. If the layer or the bones are not exactly centered you will have to slide the points in to the correct position.

Now check to make sure it worked by click on bones with the bone tool while still having the vector layer selected. The bound points will become selected showing that the binding was properly flipped.

Any questions or comments please post them here.


UPDATED! Copy and Flip Bones menu script and Rename Bones menu script

Updated: June 25, 2008


Place these scripts in the scripts/menu folder of your Anime Studio Pro application directory.

OR just add them as tools to your scripts/men/tool folder. Then you must edit the _tool_list.txt file and add these scripts as buttons (see the description above for the point flipper).

UPDATED!Now flips angle constraints and angle parent values (still working on the others)

Bone Renamer script. Very simple to use. Either replace text in a bunch of bones or append text to the end of each bone name like an extension. Select any number of bones and run the menu script.

I made this for use with the copy flip script. Now you can easily add or change the extensions on all the bone names.

Here is a sample file you can use for testing. It is the same file I used in the instructions below:

Create one side of a skeleton or symmetrical bone rig and copy and flip to the other side.

Completely FIXED 100% functional!
(I still haven't added the translation constraint values or the dynamic constraints but the other errors are fixed)

Script copies and flips angle limitation constraints and also the angle parent constrain values.

Angle constraints (or limits at the top) are "flipped". The negative minimum value is swapped with the max value. Both values have their negative/positive values flipped.

For instance a bone with angle constraints; min: -100 max: 50; will be copied and flipped with these values; min: -50 max: 100.

I am still working on the translation and scale constraints. I just did this quick because I needed it right away.


This script only works on frame 0.

No bone needs to be selected.

Just run the script. Flipping is based on the LAST in the "chain". The root bone of each "group".

For instance if you have a chest bone and all the arm bones have the extension _right at the end of the name running the script will flip those bones using the chest bone as the center axis for flipping.

All of the bones you want to flip must have an extension at the end of the bone name. If you have multiple sets of mirrored bones you need to make sure the "extension" is different for each set for something like hips or chest.

For example
If all of your "flipped" bones have the same extension, for example _right then running the script will flip all the bones.

If you only want to flip the arm bones, change the extension to something else and use that in the script dialog box for the copied extension

For example thigh_hips-rt or thigh_h-rt or bicep_chest-rt or bicep_c-rt. This name would be used for a bicep since it would most likely be a child of the chest. You can always use the bone renamer script later to change all the bone names after you are finished.

Using Bone Renamer with Copy Fip Bones
As a sort of "helper" script to go along with this one I created a menu script (see link above) that will add or replace text in the names of selected bones. So you would select a bunch of bones and add an extension to the end of the name. Or you could select bones and change or remove an existing extension. This will make the Copy Flip script easier to work with.


To use the Copy Flip Bones script select just select it from the scripts menu. The image below shows a bone selected but this is no longer necessary. You don't have to select any bones to use the script![/b]


In the dialog that pops up shown below, there is a check box for flipping, a text field for the "copied" extension and "pasted" extension. The "copied extension" is for the existing bones. Type in the name you used to identify those bones. "Pasted extension" is the new "extension" for the pasted bones.


If "flip" is checked all of the bones that are named with the extension indicated by typing in the first box will be copied and pasted on the other side of their corresponding root bone with a NEW extension indicated by the second text box.

If "Flip" is not checked all of the copied bones will just be pasted on top of the originals but with new names based on the second text box.

Below is the result of running the script and copying just the bones that were designated with an extension for the arms. Note there is an angle constraint on one of the "finger" bones. It is copied and transfered to the new matching bone on the opposite side:


Angle or parenting of the root bone makes no difference. If the root bone of the copied flipped bones is rotated the bones copied and flipped with reflect that rotation. they will be "mirrored" to the "opposite side" of the rotated bone.

Copied Attributes
Almost everything (see below). Angle, length, position, strength etc.

Bones that have NO PARENT should not be copied, meaning do not add and extension and use the script with that extension. the script will fail.

Remember that flipping is based on the last bone of the chain that DOES NOT HAVE A MATCHING EXTENSION. If you for example added the extension to the chest bone and ran the script it would copy/flip based on IT'S parent. Basically you would get unexpected results.

Translation, scale and dynamic constraints are not copied.

Future updates

This went pretty well and I don't see why it can't be extended further. That is why I deleted my previous section here about the other "copy/paste" bones script. I plan to use the code from this script since it is pretty much mine and I understand it.

A future update for this script in particular would be adding in the rest of the constraints; translation, scale, dynamics.


NEW! Bone Groups Tool Image

Updated: Dec 19, 2007


Taken off line temporarilly. It works fine but I decided to complete ALL the tools and fix various "problems". So far so good.

Issues being addressed:

Layers with the same name
The grouping is based on the layer name. I have fixed the problem with layers that have the same name by adding a simple function that alters the name of a selected layer if there is another layer at the same level with the same name. It only checks bone layers for now. All other types can have duplicate names since it has no effect on bone groups.

Child layer animation
A problem with the last set of scripts had to do with layer animation. If a vector layer was translated, scaled or rotated etc, the bone grouping didn't draw correctly. This is fixed.

Modified tool set
I have modified ALL OF THE FREAKING TOOLS! All of them... draw tools, layer tools... the whole thing. That was fun! Actually it isn't so bad now. All of my custom tools only have a simple reference to my utility script. I won't have to touch them again after this.

Bone selection of "hidden" grouped bones
I am still working on this one although it works... sort of. The problem is that even if you can hide grouped bones and "deactivate" selection of those bones, the "hidden" bones are still "there" as far as AS is concerned. They can get in the way of selecting bones "underneath" them. I want to have bone selection based on selecting MY bone coloring system. Instead of selecting a bone through the application UI the bones are selected based on clicking on the bone groups bone shapes in the new script. this would mean no more trouble selecting through a pile of bones. If a group is hidden it can't get in the way of bones under it.

I made a lot of mistakes up to this point. I apologize for that. I will try to make sure the big issues are fixed before posting the new scripts. I hope some of you will give it another shot when it's ready.


NEW! Aim Bone layer script

Updated: Sept 14, 2007


This contains a sample "leg" walk cycle Anime Studio file along with the script. Both should be in the same folder.

Here is a new sample file including script of a stick figure with arms:
http://www.lowrestv.com/moho_stuff/scri ... ot_rig.mov
http://www.lowrestv.com/moho_stuff/scri ... ot_rig.zip

This is still a work in progress. I have used a "separate" control rig that is labeled in the file that moves the leg bones.

The following two files don't contain the script file. Place these Anime Studio files in the same folder with the script from the above download.

Crank shaft sample file.

Arm sample file. Rigged arm with "3D" motion.
You can't parent an aimer bone to another aimer bone. You can parent an aimer bone to ANOTHER target bone but not its OWN target bone.


Added scale limits. Not a perfect solution. The bones won't scale when dragged too far but they will "disconnect" at the joint. I don't find this to be too bad and just keep an eye on the bones so they don't disconnect... too much. ;)


http://www.lowrestv.com/moho_stuff/scri ... m_rig1.mov
http://www.lowrestv.com/moho_stuff/scri ... im_arm.mov
http://www.lowrestv.com/moho_stuff/scri ... m_bone.mov

This bone layer script will make a bone rotate and scale to reach a target bone. The bone controlling the "shaft" in the third animation above is the "aimer" bone. There is another bone that is a child of a bone that rotates around the wheel. This child bone is the "target". The aimer bone rotates and scales to aim at the offset rotating target bone.


The script works with pairs of bones. The "aimer" bone and the "target" bone. Both bones must have the same name with an extension.

Name the aiming bone (the one that will stretch and rotate) with the extension:


Name the target bone with the extension:


Bonus Features!

Works with any number of parent bones for either bone. The aimer or target bone can be translated and the aimer bone will "stretch" to maintain its connection to the target bone.


Hey Vern Select Bone Tool - with scrolling bone selection menu

Updated: June 6, 2007




This is an alternative to the current bone selection tool. This will display the bones in a scrolling text list instead of a drop down menu. This is great for those of us with lots and lots of bones but limited screen space.


I admit there were problems with my code originally. BUT IT WORKS NOW I AM SURE OF IT!

Please give it another shot. It will be worth it.

I fixed the script so it selects bones MUCH FASTER. I took out the bonus "Crashing" feature. No one seemed to appreciate it and it would have been hard to support. ;)

The items are named correctly now at the top of the window.

I fixed the variables so it works along with the original bone selection tool.

I fixed deleting of bones (that never worked).

I have spent a lot of time testing this with ASP on a file with nearly 300 bones so I am confident that it works. It may work with the original Moho as is but I have not tested that.

I have included new icons for the tool so it shows up differently in the tool palette. You can always change the _tool_list.txt file if you want this one to be the main select bone tool.


You can change the size of the popup box by opening the script in a text editor and look for this code near the very top:

Code: Select all

-- Change the size of the bone list scroll box here
BoneListWidth = 350
BoneListHeight = 400
Change the width and height variables to whatever size you want. The numbers represent pixels.


Just unzip and drag the contents of the folder to /scripts/tool/ directory inside your AS folder and launch AS.


When you click on the Select Bone menu at the top of the document a window pops up with a scrolling list of all the bones in the current layer. You can select any of these bones and see them highlight in the view.

Bonus Features!
The current selected bone will always be highlighted in the list. With long lists it will "jump" to that spot so no need for a lot of scrolling.

You can select bones in the view and they will highlight in the list. The list remains "active" while it's open. Try that with the original bone select tool. ;)

Scroll wheels work with the bone list.

The list will "remember" the last bone selected and highlight it in the list even if you have deselected it. Just click on the Select Bone menu again click on the highlighted bone in the list and click select.

Setting constraints is a little easier now. Leave the bone list open and then open the constraints pop up to change the settings. You still must CLOSE the constraints window to select another bone but now it is much simpler to find the bone you need.

Due to the nature of text lists ALL bones are in the scrolling list. Not just named bones. There is no workaround for this at the moment. A text list has no ID for the individual items in it. The ID is just its placement in the list from the bottom to the top.

If I skip unnamed bones... then the list is out of wack. If I use names for selecting bones... then you can't have bones with the same name, or unnamed bones. It's a lose lose situation kids. I will see what I can do.

Other than the scroll box and listing unnamed bones it should select bones just like the other one.

Keep in mind this is a specialized Select Bone tool. All other bone tools will still use the old drop down menu. If you want the other bone tools to use this style of selection then I will have to rewrite the whole bone tool set. I can if anyone wants it.

I will post updates when I make any changes. Let me know if you have problems or suggestions.


The "Flipper"

Updated: May 23, 2007

Download: flipper.zip


I think I fixed this now! Download again and try it out.
Currently this script will crash when using the undo. It also may crash when deleting key frames. I am working on this. It happened towards the end of development. It wasn't doing this earlier so it must be "fixable".

This is a work in progress and should not be used for any final projects.

I still have quite a few things to add to it so some of the instructions below may change.

There is a simple file included in the zip archive... and when I say "simple" I mean it is absurdly silly and very simple. Basically just some bones and layers to show functionality.

Here is an animation (this is the old one but looks the same):

Incorporated TransRotate, RotateTrans, TransScale, RotateScale, etc etc.

This is separate controls from the flipper. These are like constraints but they mix and match types of bone motion.

Name pairs of bones with the same name as shown below in the examples:

A pair of bones. Only 2 bones per set. You can't have more than one slave. If you don't have a matching set you will get errors.

The .mst bone is the "master". The .slv bone is the "slave". The 2 letters at the end of the extension determines the type of relationship;

TR = TransRotate - Translation of master rotates slave
RT = RotateTrans - Rotation of master translates slave (x only)
TS = TransScale - Translation of master scales slave




Both bone names MUST be the same except for the extension.

Instructions for the Flip by Bones section of the script
The Flip By Bones script for flipping layers is great but... I can flip any value including bones.

This script will flip a layer, a bones rotation, scale or x translation (no y translation yet)

Requires 2 MANDATORY bones with the following names:

flip bone
now bone

There is a bug at the moment so I wouldn't recommend these bones have different parents. They can but if you move the parent in any of the frames it messes up the flipping. If both bones have the same parent that works fine.

On frame 0 make sure that both bones have the same x translation value and that they are rotated at 90 degrees. And make sure if these bones have a parent that the parent is oriented correctly so they translate properly. I've run into that problem.

Then name any bone you want to "flip" its value with either .flipS or .flipR on the end of the name and it will mirror the scale or rotation on either side of the flip.

When you drag the flip bone in either direction past the now bone the flip occurs.

I've also added in layer flipping.

The layer flipping is completely different from the script below. It doesn't have the option for bone "triplets" and the layers are named differently.

Set the depth sort of the bone layer to sort layers by depth.
Any layer you want to flip set its z translation on frame 0 to any value higher than 0. This value will be used for the flip.

To flip the z depth of a layer with this script just add one of the following to the front of the layer name:


So for example a layer might be named:


The name must have the hyphen after left or right to work. The script searches the layer names for "flip-left-" or "flip-right-".

Future enhancements:

Option for additional flip bone sets.

Flipping translation (x and y).

Add in flipping on the Y axis/translation using optional Y flip bones. (this should be cool!)

Flipping "range" for layer flipping so that layers can be on top if the flip bone is within a certain range of the now bone.

Let me know if you have any suggestions or comments by replying here.


Hey Vern's Flip By Bones

Updated: May 6, 2007

Download: HV_FlipByBones.zip


There is a text file with instructions and a sample Moho file included with the zip file.

I have modified the original FlipByBones script created by Rasheed. This new version creates only one key for the controlled layer or layers on frame 1. By keying the translation of a layer on frame 1 it effects the entire animation time line.

By doing it this way it reduces the complexity of the script and removes the necessity of calculating changes from key frame to key frame. It evaluates the positions of the control bones on every frame and updates the key on frame 1 only and maintains the original z translation on frame 0.

The instructions below are nearly identical to Rasheed's. The only change is that any type of interpolation for the bones translation works without problems.


This script should be embedded inside a bone type layer. The bone layer should contain pairs or triplets of root bones. Each bone in such a bone pair or triplet should have the same name as one of the child layers, with either ".now", ".flip" (for a pair), ".flip1" (for a triplet), or "flip2" (for a triplet) as suffices (without the quotes). These bones should not be attached to any layer.

The dynamically controlled layer (controlled by the bone pair or bone triplet) should be offset in the z direction by layer translation in frame zero. This layer translation is copied to frame one. In all other frames, if the bone.now is left of bone.flip, the z coordinate of the layer "bone" is inverted (negative value become positive, and vice versa). Or, in case of a triplet, if bone.now is not horizontally between bone.flip1 and bone.flip2, the z coordinate of the layer "bone" is inverted.

The script will add a key on frame 0 for layer translation with step interpolation to the dynamically controlled layers. The sample file contains two bone layers with each type of control demonstrated.

Don't forget to turn on "Depth Sorting" in the bone layer ("Depth Sort" tab of the layer properties), and, in the Project Settings, check "Enable 3D camera" and "Sort layers by depth".

Features and limitations

No features, no real limitations. The only thing to keep in mind is that as you you move a bone the layer z translation won't update imediately. You just need to click on the key frame or scrub through the time line and it will update.


Action Dat Import

Updated: April 4, 2007

Download: hv_actionlipsync.lua


Forum member Ramón López had created the same script a while ago which I never knew about. It has more features and error checking and can be downloaded from this thread:


It is the linked word "Here" in the last post.


Import dat files from Papagayo that use actions in ASP instead of switch layers for lip sync.

Uh... that's it really. Isn't that enough? ;)

Basically I have created this so I can use Papagayo for lip syncing my new face rig characters which use bones for all facial expressions.

This script could be used for ANY character file that uses actions for mouth positions or any other type of thing.

Instructions for use:

As far as I know scripts can only be used with ASP.

Place this script in the /scripts/menu/ directory of your ASP application installation directory. Or you can put it in the "other" directory.

On any layer, create the 10 phonemes that are required by Papagayo as named actions or any custom phonemes that you have added. This works exactly the same as using dat files for switch layers so what ever worked before will work with this.

Make sure the phoneme actions are on frame 1 and are not more than one frame in length. Sometimes lip synch has the key frames right next to each other and I don't know what would happen with actions that overlap.

Select the layer with those actions and choose this menu script from the scripts menu. After the prompt select the dat file for the lip sync you created using Papagayo. It will place a copy of the action named for each phoneme on the correct frames of the time line for that layer.

Features and limitations

There are no features... yet. There is no error checking so this means you MUST have all the basic named action/phonemes required by Papagayo or you will get an error.

At this point it only places copies of the actions not a reference. I will put in a check box for choosing this when I do all the error checking for if an action isn't available.

Future enhancements:

I plan to add in a choice for placing a copy of the action or a reference. I will do this when I add in the error checking.

Last edited by heyvern on Mon Jul 05, 2010 5:08 pm, edited 69 times in total.
User avatar
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern » Wed Jan 31, 2007 6:45 am


I did it I did it!!!

I modified a script from The Narie (copy/paste bones) so that it will paste the bones in alphabetical order.

Now the trick is to figure out how to get the constraints in there. It would appear that The Narie did put in the code to do this but maybe it wasn't working. I should be able to do this.

This will be enough for what I need. Just copy/paste to a new bone layer to reorder my bones. Eventually I would like to do this kind of thing directly to a bone layer.

User avatar
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern » Wed Jan 31, 2007 7:34 am

I had an older version of Tha Narie's copy/paste bones scripts.

I put the new stuff I did into the newer version of the paste script.

So you could have two versions of the paste bones script depending on what you need.

Haven't heard from Tha Narie here in ages.

I am guessing he fixed whatever might be causing a crash deleting bones since it doesn't happen for me.
Not true. It does crash but only when clicking on a VECTOR layer after deleting a bone. If you save the file and reopen it it's fine though.

Amazing being able to finally copy and paste constraints AND being able to nicely order my 150+ bones by name.

I will post my modified version of the paste bones script as soon as I clean it up a bit. I'm a very sloppy programmer and need to format it a little better and remove all my commented "test" code. ;)

Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete » Mon Feb 05, 2007 12:08 am

just waiting for the new version of copy / paste bones!!!

One question. Could you post an example of an moho / anme file to ilustrate the select and delete a bone with the "old" select bone tool, who shift the constraints?? I cannot reproduce the "bug".

User avatar
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern » Mon Feb 05, 2007 5:27 am

It only happens when a constraint target was created AFTER a bone you wish to delete.

AS doesn't use the name of a bone for much except selection from the pull down menu. Almost all the stuff is done using the internal "invisible" ID number that is ALWAYS CHANGING if you delete bones... or copy paste bones. The internal bone ID list is always in sequential order. If bone "Jughead" has ID 5 and a bone ID 4 is deleted, "Jughead" gets a new ID of 4. 4 is gone. The list fills the gap.

Here is an example:
Turn on auto bone/shape naming in the prefs.
Create 10 bones. Their internal ID numbers will be 0-9. The bones will automatically be named 1 through 10 in the order of creation.

Put any type of constraint on bone 10 (ID 9) to bone 6 (ID 5). Position, angle, scale, it doesn't matter.

Now delete bone 2 (currently ID 1).

The constraint on bone 10 (now it is ID 8) will shift from bone 6 (now ID 4) to bone 7 (now ID 5) since with one of the bones "missing" the ID's change in sequential order. With bone 2 gone, all the IDs shift down 1 spot. Only bone 1 doesn't change. It is still ID 0.

As long as all of your constraints are on or to bones BELOW or LOWER in order of creation (older bones are lower in the order in the bone list) than a bone you are deleting, everything is fine. BUT if you delete a bone that was created BEFORE a target of a constraint... it messes things up.

For instance with the same file you just created, put a constraint from bone 1 (ID 0) to bone 3 (ID 2). Now delete bone 7. Nothing changes. The constraint target doesn't change it's ID since it was created BEFORE the one you deleted.

This can seem kind of confusing... which is why my new bone selection tool above I added a text box that shows the bone ID along with the name. I find this useful for keeping track of stuff and writing scripts that deal with bone IDs.

p.s. Funny thing, I kept using my new bone select tool to describe the "bug" and it didn't happen. I had to reinstall the old one again temporarily to write this description.

Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete » Mon Feb 05, 2007 4:51 pm

I think I didn't follow properly your instructions... or you need to update your Moho to Anime Studio version.

http://amanoalzada.iespana.es/HV_select ... _test.html

I cannot reproduce the problem. Sorry.

User avatar
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern » Mon Feb 05, 2007 5:05 pm

They fixed it!

Dagnabbit. I have the windows version of AS but I still use Moho on the Mac. Good grief.

I will check the code of the bone select tool for AS and see what's going on their.

User avatar
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern » Mon Feb 05, 2007 5:21 pm


Looks like they added a bunch of stuff to ASP as far as scripting. I will have to do more testing with AS on the PC until I can get a copy for the Mac.

I'm just glad what I've done so far still works in AS.

User avatar
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern » Wed Feb 07, 2007 6:31 am


Updates on the new Copy/Paste bones menu script progress and a question for you folks..

It is fairly close to a test version. Basically will do exactly what it did before including copying constraints (without crashing on paste! Woohoo! Thanks to Fazek for that tip).

The question is regarding copy/pasting of bone dynamics. Bone dynamics can be keyed on and off. However I can't figure out how to copy the key frames.

Okay.... I'm lying. I probably could figure it out... but I'm too lazy to bother since I never use bone dynamics... or when I do I don't key them on and off. Plus, how many keys and how hard would it be to duplicate that info after pasting the bones anyway?

My question is whether copying bone dynamics key frames is a deal breaker? I'd just as soon leave it out to save the effort.

Let me know.

Other than that it works okay so far. Not quite ready for public consumption yet. It was harder than I expected to convert from check boxes to text list fields.

Also, I am thinking of doing the whole thing in one script. For instance you would select a bone layer and hit the "Copy bones" tool or menu (I'm leaning towards a tool). In the menu you would choose the from and to layers in pull down menus. Select the bones to copy and presto... the bones are copied from one layer to another in one step... big long script though.

Currently I am adding in "constraint target inclusion", very much like copying the parent bone. I want it to always copy the constraint target bone of a constrained bone and reassign it properly when copying and pasting if the constraint target is not included in the selected "bones to copy" list.

Also adding in name filtering. Copy bones with a specific extension/prefix or what ever.

I hate the dang interface design tools... Dr. Dolittle's stupid "Push-me-Pop-you" is crapping all over my layout. ;)

I also need to know what kind of new stuff was added to scripting for ASP (compared to Moho). Apparently there are some new "gizmos" I'm not aware of dealing with menus. Is there a new ASP Scripting Reference?

User avatar
Posts: 3376
Joined: Fri Oct 29, 2004 2:13 pm
Location: UK

Post by jahnocli » Wed Feb 07, 2007 4:42 pm


Why don't you do what every other software developer seems to do -- release it before it's ready? (Er, I mean, engage in a beta-testing programme). Beta-testers would find these things out for you, in return for a modest reduction in the cost of the software (hint hint)...
You can't have everything. Where would you put it?
User avatar
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern » Wed Feb 07, 2007 5:43 pm

I plan to do that... as soon as it does something besides... not pasting the bones correctly... or crashing AS!

I am close to a one script solution but I'm having some issues. Need to step away and let it percolate in my brain.

User avatar
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern » Sun Feb 11, 2007 10:00 pm


I can't... believe it....

This whole time....

I was using Tha Narie's original script for my template. It worked but sometimes there were strange bugs. When bones would go crazy and be rotated at odd angles.

I tracked it down to a MISSPELLED LOCAL VARIABLE!

One... simple... uppercase "I" that should have been lower case and it breaks the whole thing on very specific situations.

This mispelling was almost invisible:

Code: Select all

doFix = false

doFIx = false
If you don't look really really close... you will never see it. The top of the "I" blends into the "F" in both and looks the same. (it looks much worse with the text editor I am using.)

This was buried deep in the code and has been there from day one.

Holy cow. Holy cow. Yikes! I have much respect and appreciation for programmers. Imagine multiplying this by a thousand or a million. Tracking down bugs must be a NIGHTMARE for you guys.

Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete » Sun Feb 11, 2007 10:43 pm

I'm happy you find out the missspeling variable!
I have sometimes the copied bones in strange positions.
I only want to cheer you up to continue finishing the copy/paste bone script.
It is very useful.
See you.
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete » Sun Feb 11, 2007 10:53 pm

By the way why don¡t you add this script to this thread?
It is a really needed embedded script.
Best :)
User avatar
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern » Sun Feb 11, 2007 10:56 pm

After finding this problem I have solved 99% of the errors that were occurring... that 1% though... sheesh!

I should have a basic working version soon. I plan to just get it to work as it did before with out a bunch of fancy name filtering yet.

The layer picking works GREAT!!! Pick any layer, copy to any layer. All from one script window.

The errors I'm tracking down now have to do with some of the original options that Tha Narie put in that are conflicting with the new text list display of bones (as opposed to check boxes).

Sad to say that most of the problems with Tha Narie's original script had to do with that misspelling.

I am still glad I took this challenge on. I've learned a lot and the end result will be a kick arse bone copier.

I've added a new feature to my list for future enhancements... renaming of bones when copying to the same layer. This would allow duplicating constrained bone rigs within a bone layer. Very coooool!

Post Reply