Alphabetize bone name list in a table or array?

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

Moderators: Víctor Paredes, Belgarath, slowtiger

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

Alphabetize bone name list in a table or array?

Post by heyvern »

Okay,

I've figured out how to keep track of bone IDs and constraints. What I want to do is create a menu script that will reorder the bone list by name in alphabetical order.

I don't know how to do this in LUA. Is there a tricky command for this? Something to do with lists and tables? I did a search on the web and couldn't find anything.

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

Post by heyvern »

Nevermind!

Code: Select all

table.sort

<sigh>

-vern
User avatar
Touched
Posts: 504
Joined: Mon Dec 11, 2006 7:33 am
Location: Sunny California
Contact:

Post by Touched »

That would be useful for me. Also useful would be a menu command to sort the names of styles. Could such a thing be posted?

Come to think of it, is it possible to make a script to combine what should be identical style names, which get the file name added in front of them if you import an Anime Studio object?
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

My immediate need is to manage 160 bones. I desperately need a way to organize them by name. Otherwise I have to redo my face rig from scratch in the correct bone order which... isn't working out to well for me. I need this one bad.

It looks doable. I did manage to "fix" the bone select tool so that deleting a bone doesn't mess up all the constraints. I am so happy with that one. Will be posting it later.

I would expect the exact same thing would apply to styles. During this "process" with the bone script I kept stumbling across the same things with shapes... and actually thought it might work for that as well.

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

Post by Genete »

heyvern wrote:My immediate need is to manage 160 bones. I desperately need a way to organize them by name. Otherwise I have to redo my face rig from scratch in the correct bone order which... isn't working out to well for me. I need this one bad.

It looks doable. I did manage to "fix" the bone select tool so that deleting a bone doesn't mess up all the constraints. I am so happy with that one. Will be posting it later.

I would expect the exact same thing would apply to styles. During this "process" with the bone script I kept stumbling across the same things with shapes... and actually thought it might work for that as well.

-vern
Dear heyvern,
I've followed some of your posts regarding to the problems that you have with the quantity of bones in your face rig. I wonder if really all the bones need to be named.
I can figure two reasons to need the bones named:
1) The bone is used to another bone constraint.
2) It should be named to be able to select it due there are more than one bone at same place.

I can suggest to you some hints (if I can...)
a) Use auto name bones is a good thing. But the number of named bones increases quickly.
b) Regarding to constraints (case 1). If there are bones that are constrained by others they should not be neccesary to be named... Unless it is a constraint of other bone... But, if the second constraint is applied in the same constraint channel (for example bone C moves its coordinates as bone B moves and bone B moves its coordinates as bone A moves) then you can avoid to name the bones B and C due to bone C depends on bone B that finally depends on bone A. Speaking in a math language :P :if C.x=f(B.x) and B.x=g(A.x) then C.x=f(g(A.x)). I mean you can conpound the constraints to avoid cascade naming of bones. With this you can avoid a lot of bones named.
c) Regarding to some bones at same place (case 2). You can do some things: First try to put the 50% influence bones placed in inverse direction. It have the same effect and allow you to select the bones easely although they have exactly the same influence region. For example: you can have a bone with this values:

Bone A: x=0; y=0; lenght=0.2; angle=0; strength=1
Bone B: x=0.2; y=0; length=0.2; angle=180; strength=1

Both bones have exaclty the same influence region but you can select them easily.
**This is valid only if bones are only used to be moved. If the bones are going to be rotated obviously the influence region is the same but the rotation produces different movement of the point(s).**

Bun in case you have more than two bones in the same place (I know you have it) to avoid name the bone you can do other thing. Attach a child bone to it in a easy selection position. Using the up arrow you can select its parent that is the overlapped bone.

Finally I don't know if you understood how to unname a named bone. It is as easy as select it erase its name and press enter. It will dissapear from the list.

I hope it will help to you. If all this hints were known by you and were already applied... Good grief!! you have a lot of bones!

Regards
Genete
User avatar
Rasheed
Posts: 2008
Joined: Tue May 17, 2005 8:30 am
Location: The Netherlands

Post by Rasheed »

This opens ways to make some of your bones anonymous. Of couse, an anonymous bone is simple a bone which has an empty string ("") as its name.
Genete
Posts: 3483
Joined: Tue Oct 17, 2006 3:27 pm
Location: España / Spain

Post by Genete »

One remark. This hints don't solve the problem with the copy/paste bones menu scripts. If you have lots of them it does not matter if they are named or not. Perhaps it could be better modify the menu script to a new one called: "copy selected bones..." and no selection of bones if offered in the script window.
Regards
Genete
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

I've thought about not naming all the bones...

It freaks me out! ;)

No really, it scares me a little to think of having bones without names. I've been in that situation before and quite frankly it isn't worth the trouble. There can be times when a bone is nearly impossible to select if it doesn't have a name.

Plus without a name there is absolutely no way to know what it does. That is almost as bad as not being able to select it! If a bone has no name, I won't know if maybe I don't need it, or... why it's there.

I've decided... all the bones MUST have a name.

Also I am in the process of converting the copy/bones script from check boxes to scrolling text boxes. Instead of a HUGE list of check boxes, there will be 2 scrolling text fields.

The first field has a list of ALL the bones. The second field has a list of the bones to be copied. Simple click on a bone in the first box it appears in the second box and is removed from the first. Select it again in the second box and it goes away and appears again in the first box. Not as visually appealing but it certainly fixes the size issue for me.

The code works perfectly with those text fields I just have to populate those fields with the bone lists so that the script does its job.

-vern
User avatar
Rasheed
Posts: 2008
Joined: Tue May 17, 2005 8:30 am
Location: The Netherlands

Post by Rasheed »

Would it be possible to display only certain types of bones (root bones, parent bones, control parent bones, etc.) in a pull down menu, so you wouldn't have all bones exposed to the animator?
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

RASHEEEEED!

You're a genius!

Of course! I could have a specialized bone selection tool that displays only the bones I need! I can use a check box on the window for the tool to only show certain bones, or only show bones that have a specific prefix or extension!!

I am going to have to play with this idea. I really like it.

p.s. Did you see my new bone selection tool that deletes bones without messing up constraints? That thing rocks.

-vern
User avatar
Víctor Paredes
Site Admin
Posts: 5814
Joined: Wed Jan 26, 2005 12:18 am
Location: Barcelona/Chile
Contact:

Post by Víctor Paredes »

Rasheed wrote:Would it be possible to display only certain types of bones (root bones, parent bones, control parent bones, etc.) in a pull down menu, so you wouldn't have all bones exposed to the animator?
that would be fantastic!
User avatar
heyvern
Posts: 7042
Joined: Fri Sep 02, 2005 4:49 am

Post by heyvern »

Oooo!!!

Even better! Multiple pull downs! No check boxes. Just pull down the menu of the type of bone you need to see.

Oh wow! This could be a temporary fix (wink wink) until we get a scrollable bone selection menu list.

Oh crap! I have to check and see if you can put SCROLLTEXT inside a popup!!!! Like the constraint popup? That popup has stuff inside it and is created just like other pop ups. I could put the scrolling bone list inside a pop up gizmo.

Holy cow! If I put special tags on the names of control bones I could select them all at once and change SPECIFIC THINGS.

For instance if I select a whole pile of bones that have DIFFERENT position constraint parents but the same VALUE, I could change the value on them all without changing the parent as the current bone selection tool does.

p.s. I need these tools to aid in my face rig. At the moment it is a nightmare to edit. These additional tools will help streamline the process.

-vern
User avatar
Rasheed
Posts: 2008
Joined: Tue May 17, 2005 8:30 am
Location: The Netherlands

Post by Rasheed »

Sometimes it pays to take some distance from your programming problem, to see other angles you hadn't considered before. That's why good programming takes time, just like good animation.
Post Reply