PDA

View Full Version : Probably noob mistake. . .


Epopisces
10-02-2005, 04:49 AM
Ok, I am trying to create a rig, decked out with all the coolest tricks and toys that I don't yet know how to make (sounds like a plan, right? :wise: lols). Anyway, I've been trying to figure out how to, when a certain curve is selected, deselect it and select three Clusters instead (which control the curves shape, and the deformation). I'm trying to do it with scriptJob command, as for whatever reason I couldn't get an equivalent script to work as an expression.

Note: I had more comments but they were more to explain to myself all the different commands, and some were. . .lame so I removed them for public viewing (=.
LowerBrow and UpperBrow are the curves in question, with the Clusters all being named starting with 'Lower' or 'Upper'. The Clusters are one on the rightmost cv, one on leftmost cv, and one cluster is on the 2 center cvs, for each of the curves.
Here it is:

//the whole purpose of this script is to change the selection of one thing to another

scriptJob -e "SelectionChanged" LJGReselect;
global proc LJGReselect()
{
int $twoSel = 0;
//Discovered a VERY handy part of list command; will list all selected objects ending in //"erBrow" (so in this case, LowerBrow and UpperBrow but NOT UpperRightBrow.
string $allSelected[] = `ls -sl "*erBrow"`;

switch ($allSelected[0])
{
case "LowerBrow":
select "Lower*";
$twoSel = 1;
break;
case "UpperBrow":
select "Upper*";
$twoSel = 1;
break;
}
if ($twoSel == 1)
{ switch ($allSelected[1])
{
case "LowerBrow":
select "Lower*";
break;
case "UpperBrow":
select "Upper*";
break;
}
}
select -d UpperBrow;
select -d LowerBrow;
}

//WARNING: Mucho buggos. This script destroys the undo function
//when it involves the curve in question. Much work needed!


Yeah, my problems are:
1. Undo stops working when used.
2. The clusters cannot be UNselected once they are selected using the script.
3. For whatever reason when the UpperBrow and LowerBrow curves are deselected, they remain highlighted as if still selected.

If anyone has a solution or better method, have pity on a poor MEL-noob. . .

malcolmTG
10-06-2005, 01:42 AM
why are you trying to make it select those other three things anyways?

if youre just trying to move those around as one thing then why not make the curve control the position of the clusters. it seems like a lot of extra stuff if thats all youre trying to do.

harmless
10-06-2005, 04:11 PM
Here is your script, but fixed and shortened.
Sorry for the comments but it's to help you learn :)
Call it tough love ;)
Oh, and rename your cluster targets to Lower_obj1, 2,3/Upper_obj1, 2, 3 etc for this
script to work...


// This is a terrible way to do things!
// Scripts/code that relies on string names are the suck.
// If I select the *erBrow things in the scene the design of this script will break undos!
// For instance, if I selected LowerBrow and it selected the Lower_obj1 then I called undo()
// It would undo to re-select LowerBrow and call this scriptJob again! Bad design!
scriptJob -e "SelectionChanged" LJGReselect;

global proc LJGReselect()
{
// I hope the *erBrow objects weren't renamed!
string $browCheck[] = `ls -sl "*erBrow"`;

switch ($browCheck[0])
{
case "LowerBrow":
select -d LowerBrow;

// Rename your clusters to something like Lower_obj1, Lower_obj2, etc...
select -add "Lower_obj*";
break;

case "UpperBrow":
select -d UpperBrow;

// Rename your clusters to something like Upper_obj1, Upper_obj2, etc...
select -add "Upper_obj*";
break;
} // end switch

} //end global

Epopisces
10-08-2005, 04:58 PM
Thank you! Believe me, no offense taken, everything you said is true and necessary (it's only when my mother starts entering the comments that I bristle a bit :).) so thanks for all the comments.

Always good to learn more. Looking at this revision, because of the (unwise) way I set it up it would still create an undo loop correct? That is, because when you undo to a certain point the *erBrow object would be reselected, runnning script again, etc.

I thought about it and I couldn't come up with a way around having that happen with a 'SelectionChanged' scriptJob. . .unless somehow you make sure that when undo occurs the object is either 1) note reselected or 2) not selected first (because scriptjob looks at the first item selected). Any thoughts?

To be honest, it's academic at this point, I already finished the first version of the rig, so it would be purely for learning purposes.

Oh, and malcolm, the clusters being selected are the oned which control the shape of the curve in question. So I never want the user to be able to move the curve without using the clusters to do it (and if both are selected the curve gets double transformed, moving twice as far as you actually want it too). Had it worked, it would have controlled the character's eyebrow shapes (the character in my avatar, as a matter of fact).

CGTalk Moderation
10-08-2005, 04:58 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.