Custom Tool - Bone Groups with color and name labels

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

Custom Tool - Bone Groups with color and name labels

Postby heyvern » Wed Aug 01, 2012 6:46 pm

This is a new updated version of a script I created for ASP v5. Instructions in the zip.
This custom tool and utility script combo, allows for grouping and colorizing bones. It also displays bone names above the bone. The bone label text size is based on initial bone length. This can be a bit of an issue with very small bones. I could probably adjust that percentage to not get too small.

bone-groups-v8.zip

I modified rotate and select bone tools for the video below. Instructions for doing this yourself are below. It is not very difficult and only requires adding 3 lines of code to any tool script. All you need is Notepad or Textedit or any plain text editor.



Image


Important Notes:
1) I have not figured out how to store the data in the file yet, until I do, there is an external file created when the AS file is saved that must stay with that document in the same folder. This file requires the ".tbl" extension... not sure why I chose that extension. it is just a plain text file that stores bone grouping and color information.

A bonus for this external file is if you have two different files with the same bone names and the same bone layer name, you can copy that .tbl file, change the name to match another file, place it in the same folder as the other file and when you open it, there will be the same bone grouping set up.

2) There is a utility script that must be put in the scripts/utility folder.

Other than that it works okay. Of course it's pretty useless without being able to use it with other tools. I am still trying to work on that. There is a really nice practical use for it without editing the other tools. The bone grouping allows you to select just the bones in the group. By selecting from the menu it selects all bones in the group quickly and easily. Much faster than shift selecting the same bones over and over and you can have bones in more than one group. It works on any frame if the bones are on top of each other, you can go to a different frame for easier selection of the bones.

Modify Other Tools to display bone grouping
If you feel comfortable editing your tools directly you can add the following code to any bone tool just above the "Tool options" comment. DO NOT USE MS WORD! Or any other word processing type application. Use Notepad or textedit. Any application that can edit and save PLAIN text.

The example below was added to the lm_rotate_bone.lua tool. You only need to copy/paste the three lines of the [/b]DrawMe[/b] function and not the comment below it. That's just to show where it is in the tool.

Make sure you change the function name to match the tool. In this case LM_RotateBone:DrawMe is the function name for that tool. If it were the Select bone tool, it would be changed to LM_SelectBone:DrawMe. That small bit of text can simply be copied and pasted within the tool script.

Code: Select all
function LM_RotateBone:DrawMe(moho, view)
   HV_SharedUtils:DrawMe(moho, view)
end

-- **************************************************
-- Tool options - create and respond to tool's UI
-- **************************************************


As you can see, it's not hard to do at all and is well worth the effort until I find a way to use this tool without requiring editing of the tools. to keep things simple but functional you can just add this code to the rotate bone and select bone tools. You can turn off "Paths" in the display and only see the bone groups. You can turn bone groups on and off etc. The performance is off the hook considering how much is running in the back end of the script, drawing all the text and the bone shapes etc. It's probably because this is UI Drawing and not actual vector drawing.

With a little effort I should be able to have the bone labels change orientation so that it stays "up" for readability.

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

Re: Custom Tool - Bone Groups with color and name labels

Postby Onionskin » Fri Aug 03, 2012 7:35 pm

With this tool I finally got control over my bone chaos.
Bone coloring and grouping works just great, but bone label is not working by me.
Modified bone manipulation tool and offset bone are acting little strange on frame 0, rest of modified bone tools are ok and modified fazek translate points also.

Thank you for this tool, it will save me a lots of time,
good to have you back on forum
User avatar
Onionskin
 
Posts: 220
Joined: Wed Mar 04, 2009 2:01 pm

Re: Custom Tool - Bone Groups with color and name labels

Postby heyvern » Sat Aug 04, 2012 1:37 am

Oops!

Okay, so sorry. I had added the bone name labels to the script but I uploaded the older version without this feature.

I updated the link in the first post so the new download should do the bone name labels properly now.

However you only have to replace the utility script below to get the name labels:

hv_sharedutils.zip

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

Re: Custom Tool - Bone Groups with color and name labels

Postby heyvern » Sat Aug 04, 2012 2:14 am

Offset and manipulate bone tools don't seem to work with the modifications.

Manipulate bones is doing its own crazy stuff. That particular tool is quite different from the other bone tools. Just have to experiment with the code to see how to get it working in that tool.

Offset bones "works" but isn't taking into account the bone offset on frame 0. that is because frame 0 is "different" than other frames. It doesn't draw the same way so the live bone offset isn't being shown. Will work on these changes.

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

Re: Custom Tool - Bone Groups with color and name labels

Postby Onionskin » Sat Aug 04, 2012 9:19 am

Yes, now is all there, however I decide to stay with old utility file, text label is cool feature but collor label is more than enough for me now.

I look forward for data storage
User avatar
Onionskin
 
Posts: 220
Joined: Wed Mar 04, 2009 2:01 pm

Re: Custom Tool - Bone Groups with color and name labels

Postby heyvern » Sun Aug 05, 2012 10:22 am

I will make text labels a check box in the tool options. Good idea.
User avatar
heyvern
 
Posts: 6964
Joined: Fri Sep 02, 2005 4:49 am

Re: Custom Tool - Bone Groups with color and name labels

Postby 707dragon707 » Sun Feb 01, 2015 3:51 am

unfortanatly i dident make acopy of my rotate bone tool before adding the lines of code, and now I have two rotate bones one in my bone group and the other in th other group. Even after i removed the lines of code,and then i removed the bone group script but i still have two rotate bone tools. they were working before i added the lines of code.
User avatar
707dragon707
 
Posts: 46
Joined: Sat May 10, 2014 1:09 am


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest