View Single Post
# 9 06-10-2013 , 04:15 PM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
I don't quite know what I'm looking at. Are the comments in these current? They seem to be experiments and repeated lines that have been commented out and it's adding to the difficulty reading your code.


Also this:

Code:
spaceLocator ;
rename |locator1 "tracker01" ;
addAttr -ln "expr_Pull_Frame" -at long |tracker01;
setAttr -e-keyable true |tracker01.expr_Pull_Frame;

int $curFrame =`currentTime -q` ;
int $prevFrame = $curFrame - 1 ;
print ($prevFrame + " Previous \n") ;
print ($curFrame + " Current \n") ;

select -r tracker01 ;
delete ;
An object was created, an attribute added to it, nothing further is done with that information then the object was selected and deleted. Now you see why I was asking for clarification on how you want this thing to work.

If you needed to find out the keys set on a given attribute you could use the keyframe command.

Code:
keyframe -query pSphere1.inP01;
In this case, it'll return 1 18.

I also saw some issues in the "switchMoment" proc:

Code:
global proc switchMoment (int $curFrame, int $prevFrame, int $trackCheck01)
{
//.... here i have to define he only gives the one frame the swith goes on,
//.... else he keeps recalculation this rule every frame, and need to fetch just that one frame it switches
if ( $trackCheck01 == 0 )
{
print "Non-Active \n" ;
}
else
{
	//Gen: the code is only concerned if the value of trackCheck01 is non zero, 
        //the next if then statement specifying 
	// what it should do if the value is 1 will overwrite this
	
print ($curFrame + " Start Frame \n") ;
//string %colRed = `textField -rgb 1 0 0` ;
}

if ( $trackCheck01 == 1 )
{
	//Gen: you already told it to do something else if trackCheck01 isn't equal to 0
	//So what do you want, this or the command in the previous if then statement?
	
print "STOP Non-Active \n" ;
}
else
{
	//Gen: Same thing here, this "else" value could be turn out to be 0
	
print ($curFrame + "STOP Start Frame \n") ;
//string %colRed = `textField -rgb 1 0 0` ;
}
}

Also, you may want to consider giving your global variables and procedures more specific names. "menuDisplay" and "switchMoment" will likely run you into trouble later down the line if you start making(or downloading) more scripts. And hard coding object names into the script could prove to be problematic. Having the code depend on "pSphere1" could really limit the script's use.


About the auto updating of the current/previous frame UI elements. Since you've set those int fields to have a global scope, you can just add a couple of lines to the RT_Check proc that edits them whenever the proc runs.


Code:
	intField -e -v $curFrame inP_CF;
	intField -e -v $prevFrame inP_PF;

They could probably use more detailed names too haha. You could take this approach to the on/off controls as well.

example

Code:
//........ What to do whith what state............
if ( $trackCheck01 == 1 )
{ print "Green \n" ;

text -e -bgc 0 1 0 aDetailedControlName;

switchMoment ($curFrame, $prevFrame, $trackCheck01);

//string %colGreen = `textField -rgb 0 1 0` ;
}
else
{ print "Red \n" ;

text -e -bgc 1 0 0 aDetailedControlName;

//string %colRed = `textField -rgb 1 0 0` ;
}


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::