Complex UV Layout in Maya
Over the last couple of years UV layout in Maya has changed for the better. In this course we're going to be taking a look at some of those changes as we UV map an entire character
# 1 02-10-2013 , 01:06 PM
ieoie's Avatar
Registered User
Join Date: Aug 2007
Location: The Netherlands
Posts: 88

procedure within procedure.???

hi People.....

please know this is my second script and am also trying to understand MEL a bit better.......


i'm trying to capture the changing moment of keyed 0-1 attribute ......
this because i am trying to add a second input device to my motion capture file
it is for an art project......

the idea is to create an animation, and set it as a clip in the trax editor

then capture the moment when state of the object changes (for now a keyed object)
take the current frame and set the start of the clip in the trax editor
and add the length of the animation to set the stop of the animation

this way i can controll my test person with the kinect 360 sensor
and start stop animations that are connected to the rig whenever the second input device changes the state of my input............
since the second device is not yet connected, my question only concerns the noticing and starting stopping the animation inside Maya


this script provides me now with every frame, the current frame and the previous frames as values, and shows the state of the object

but when i now add an if / else the script crashes.......

if i create a second procedure i cannot acces the $curFrame value, or at least i do not know how....
here is a link to the file i use to test the changing state of the object....
www.ieoie.nl/downloads/0000_FLOW_EXPRESSION.zip

can someone show a way out of this situation......;-)

thank you.....

Rob...


global proc RT_Check ()
{
// expres. on locator runs every frame this procedure... "RT_Check ()"
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") ;
print "\n" ;
select -r tracker01 ;
delete ;

int $trackCheck01 = `getAttr pSphere1.inP01` ;
print ($trackCheck01 + " Visible Status \n") ;
print "\n" ;


//if ( $trackCheck01 == 1 ) { print "Green \n" }
//else { print "Red \n" }

}

Attached Files
File Type: txt RT_Check_Question.txt (654 Bytes, 491 views) File Type: zip 0000_FLOW_EXPRESSION.zip (9.1 KB, 480 views)

*
The Universe is larger then you ever can think, But smaller then the size of your imagination.

all are welcome at www.ieoie.nl
# 2 02-10-2013 , 05:48 PM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
The Maya file is empty. And right off the bat the last if then lines are going to throw a syntax error as soon as you comment them in because the statements are inside curly brackets yet are missing semi colons. My suggestion is, until your totally comfortable with MEL, make better use of white space so it's easier to pick up on these mistakes. And adding more comments wouldn't hurt user added image

before
Code:
if ( $trackCheck01 == 1 ) { print "Green \n" }
else { print "Red \n" }
after

Code:
if ( $trackCheck01 == 1 ) { 

print "Green \n"; 

}else { 

print "Red \n";

}
Also, you can create another procedure that you pass the variable(s) to.

like:

Code:
global proc doThisStuff(int $curFrame){


print $curFrame;
//and do other stuff


}
If you need to pass multiple variables then just separete them by commas and remember to define the data type(int, string etc). You can even send a mix of data types.

The RT_Check proc can call it.


Code:
global proc RT_Check ()
{
	// expres. on locator runs every frame this procedure... "RT_Check ()"
	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") ;
	print "\n" ;
	select -r tracker01 ;
	delete ;

	int $trackCheck01 = `getAttr pSphere1.inP01` ;
	print ($trackCheck01 + " Visible Status \n") ;
	print "\n" ;

	if ( $trackCheck01 == 1 ) { 

		print "Green \n"; 

	}else { 

		print "Red \n";

	} 

	//// call new proc and pass variable
	doThisStuff($curFrame);


}
Hopefully that helped. I'll stop rambling now user added image


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::
# 3 02-10-2013 , 06:22 PM
ieoie's Avatar
Registered User
Join Date: Aug 2007
Location: The Netherlands
Posts: 88

Working.....;-)

The Maya file is empty. And right off the bat the last if then lines are going to throw a syntax error as soon as you comment them in because the statements are inside curly brackets yet are missing semi colons. My suggestion is, until your totally comfortable with MEL, make better use of white space so it's easier to pick up on these mistakes. And adding more comments wouldn't hurt user added image

before

Code:
if ( $trackCheck01 == 1 ) { print "Green \n" }
else { print "Red \n" }
after

Code:
if ( $trackCheck01 == 1 ) { 

print "Green \n"; 

}else { 

print "Red \n";

}
Also, you can create another procedure that you pass the variable(s) to.

like:

Code:
global proc doThisStuff(int $curFrame){


print $curFrame;
//and do other stuff


}
If you need to pass multiple variables then just separete them by commas and remember to define the data type(int, string etc). You can even send a mix of data types.

The RT_Check proc can call it.


Code:
global proc RT_Check ()
{
	// expres. on locator runs every frame this procedure... "RT_Check ()"
	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") ;
	print "\n" ;
	select -r tracker01 ;
	delete ;

	int $trackCheck01 = `getAttr pSphere1.inP01` ;
	print ($trackCheck01 + " Visible Status \n") ;
	print "\n" ;

	if ( $trackCheck01 == 1 ) { 

		print "Green \n"; 

	}else { 

		print "Red \n";

	} 

	//// call new proc and pass variable
	doThisStuff($curFrame);


}
Hopefully that helped. I'll stop rambling now user added image



it sure did help... thank you.....
please keep rambing.... i love it.....;-)
ps, the scene wasn't empty... there was just 1 sphere in it,... the input i forgot to connect to the visibility of the sphere....oeps....sry
;-)

i tried the red dotcomma thingy, did not work earlier,
but you adding the extra curly bracket in the end did the trick i think.... am i right here.....???
like you have to close 2 procedures in stead of one???

getting the vallue in the next procedure i will try later, when needed......
thank you so much.....
me is verry happy now.....

enjoy....


*
The Universe is larger then you ever can think, But smaller then the size of your imagination.

all are welcome at www.ieoie.nl
# 4 02-10-2013 , 06:40 PM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
You closed the procedure and the "if then" block just fine, you were just missing the semi colons, that's all. Glad it worked out!


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::
# 5 02-10-2013 , 08:50 PM
ieoie's Avatar
Registered User
Join Date: Aug 2007
Location: The Netherlands
Posts: 88

Found the difference.....

You closed the procedure and the "if then" block just fine, you were just missing the semi colons, that's all. Glad it worked out!


found what i did wrong.....

you placed the dotcomma inside the curly brackets, when i tried adding them yesterday i placed them at the end of the line outside the curly brackets and that made the error......

thank you for helping me making baby steps....
user added image


*
The Universe is larger then you ever can think, But smaller then the size of your imagination.

all are welcome at www.ieoie.nl
# 6 05-10-2013 , 10:07 AM
ieoie's Avatar
Registered User
Join Date: Aug 2007
Location: The Netherlands
Posts: 88

Additional help........

You closed the procedure and the "if then" block just fine, you were just missing the semi colons, that's all. Glad it worked out!



Hi Gen,

thank you sofar, once more.... cannot do that enough.....;-)

was wondering......
i found some new things i have troubles to controll, are you willing to help with them aswell....???

- pulling the created data into a window, so i am able to visualy see which tracker is active and which not....
if i run my window from that expression the window ofcourse starts flashing, so i am trying to create just flashing intFields that i try to load in my collumLayout of the steady window.....

since you are a moderator aswell.....

should i start a new topic for this.....or just keep adding my questions to this one.....
the code i will upload to the community when ready......

i saw the forum has no Kinect to Maya manual, if you like we might can make one......


*
The Universe is larger then you ever can think, But smaller then the size of your imagination.

all are welcome at www.ieoie.nl
# 7 05-10-2013 , 01:05 PM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
You don't have to create a new topic since this is all part of the same project. There is a scripting section though. I haven't seen a lot of talk about Kinect on here and I personally don't use it so all I can do is help you with your mel scripts lol.

I'm having a lot of trouble visualizing your problem. Do you have any screen shots and mock ups of what you want this thing to look like and function?


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::
# 8 05-10-2013 , 01:48 PM
ieoie's Avatar
Registered User
Join Date: Aug 2007
Location: The Netherlands
Posts: 88

Next script step......

You don't have to create a new topic since this is all part of the same project. There is a scripting section though. I haven't seen a lot of talk about Kinect on here and I personally don't use it so all I can do is help you with your mel scripts lol.

I'm having a lot of trouble visualizing your problem. Do you have any screen shots and mock ups of what you want this thing to look like and function?


thank you.......

is this sufficiant.....
else i will make a small youtube.....
or maybe we can do screenshare through Skype and share the findings on the forum......???


//-------------------------------------------------------------------------------

global proc RT_Check ()
{
//......... expres. on locator runs every frame this procedure... "RT_Check ()".............
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 ;

//........ Tracking the state of the Atribute........
int $trackCheck01 = `getAttr pSphere1.inP01` ;
//int $emptyCall = 0 ;
print ($trackCheck01 + " Visible Status \n") ;

//........ What to do whith what state............
if ( $trackCheck01 == 1 )
{ print "Green \n" ;
switchMoment ($curFrame, $prevFrame, $trackCheck01);
//string %colGreen = `textField -rgb 0 1 0` ;
}
else
{ print "Red \n" ;
//string %colRed = `textField -rgb 1 0 0` ;
}


/* this way i hope to define/add a check that he only returns the frame when it is turned on, and not every frame after that aswell
//....................... if current frame (pSphere1.inP01 = 1)
//....................... and previous frame (pSphere1.inP01 = 0),
//.......................than give only this current frame nr, ........(this value i then use as start for the animation......)

//....................... if current frame (pSphere1.inP01 = 1 )
//....................... and previous frame (pSphere1.inP01 = 1 ),
//.......................than do nothing
*/

//passFrames ( $curFrame, $prevFrame ) ;
print "\n" ;
}

//---------------------------------------------------------------------------------------

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
{
print ($curFrame + " Start Frame \n") ;
//string %colRed = `textField -rgb 1 0 0` ;
}

if ( $trackCheck01 == 1 )
{
print "STOP Non-Active \n" ;
}
else
{
print ($curFrame + "STOP Start Frame \n") ;
//string %colRed = `textField -rgb 1 0 0` ;
}
}

//------------------------------------------------------------------
//------------------------------------------------------ EXPERIMENT-

// ........ here i am trying to find a way to to make an intfield that i can load in the menuDisplay (FrameTools)
// ...This way i think i can get some of the fields in the window real-time.....
//.Because when i now connect this FrameTools window directly to the RT_Check the whole window turns on and of every frame
//so i need to bridge this somehow...so the window updates only some specific fields each frame....

global proc passFrames (int $curFrame, int $prevFrame)
{
print ($prevFrame + " Previous \n") ;
print ($curFrame + " Current \n") ;
//string $curUpd01 = `intField -v $curFrame` ;
//string $prevUpd01 = `intField -v $prevFrame` ;
}


//------------------------------------------------------------------
// -------------------------------------------- MAKING PRIME MENU --
//------------------------------------------------------------------
proc menuDisplay ()
{
if (`window -exists flow_toolsUI`)
deleteUI flow_toolsUI;

//string $Try = `passFrames (int $curFrame, int $prevFrame)` ;

float $startFrame = `currentTime -q`;
float $prevFrame = $startFrame - 1 ;
string $animLength1 = "50 fr" ;
string $animLength2 = "75 fr" ;
string $animLength3 = "100 fr" ;
string $animLength4 = "150 fr" ;

window
-width 300
-sizeable false
-t "FrameTools"
-iconName "ieoie Tools"
-mxb off
flow_toolsUI;

rowColumnLayout -numberOfColumns 1
-columnWidth 1 300
columnLayout;
text "";
text "Real-Time On/Off Check";
text " ";
setParent ..;

rowColumnLayout -numberOfColumns 2
-columnWidth 1 150
-columnWidth 2 150

columnLayout;
text "Current Frame";
text "Previous Frame";
intField -v $startFrame -editable true inP_CF ; //... this one should be connected with RT_Check (it does not update real-time now)
intField -v $prevFrame -editable true inP_PF ; //... this one should be connected with RT_Check (it does not update real-time now)
setParent ..;
text " ";
setParent ..;

frameLayout -w 400 -h 500 -label "Tracked Object Stats";

string $objectsIntrace1 = `rowColumnLayout -numberOfColumns 5
-columnWidth 1 100
-columnWidth 2 50
-columnWidth 3 50
-columnWidth 4 50
-columnWidth 5 50`;

text " ";
text "Start";
text "Length";
text "Stop";
text " " ;

text -l "Tracked Object 001";
intField -editable true inP1_CF ; //... here comes the start frame of the animation
textField -it $animLength1 -editable false animL1 ;
intField -editable true inP2_CF ; //... here comes the end frame of the animation
text -ebg true -bgc 1 0 0 "On/Off"; //... this color should go green when active, and back red when done

text -l "Tracked Object 002";
intField -editable true inP3_CF ;
textField -it $animLength2 -editable false animL2 ;
intField -editable true inP4_CF ;
text -ebg true -bgc 1 0 0 "On/Off";

setParent ..;
setParent ..;

text "Testing real-time notification";

showWindow flow_toolsUI;
}

menuDisplay ;

Attached Files
File Type: zip 0000_FLOW_EXPRESSION_TEST.zip (8.6 KB, 490 views)

*
The Universe is larger then you ever can think, But smaller then the size of your imagination.

all are welcome at www.ieoie.nl

Last edited by ieoie; 05-10-2013 at 01:51 PM. Reason: Forgot Attachement
# 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 ||::
# 10 07-10-2013 , 12:07 PM
ieoie's Avatar
Registered User
Join Date: Aug 2007
Location: The Netherlands
Posts: 88

yes,... current comments

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` ;
}


the comments i use to outline a bit where i am going....... since i have no clear understanding of which command i can use for what i try to build......i just see where i get with my instict and google....;-)
and ofcourse now you who is helping me to define what i need to get the thingy going.....

in a sense it is one big adventure for me.....
is it possible we do a Skype one day, so i can explain you more clearly at what level i am when it comes to MEL, it looks like you think i understand completyely what you say.......
me is making baby steps here.... sry.....
i also have no official Maya training what so ever.... me is autodidact.....

the locator is as far as i know needed to add an expression to it, so it runs this RT_Check every frame.....
when it is added it keeps running evry frame so i can delete it again a few lines later....
why i do not understand.... most likely cause he re-creates after that every frame that locator....
i use this indea to recieve every frame the current frame instead of only when the timeline stops....

probably the way i want to achieve my tool is not the right way to do it,.... so if you understand what i am building, i could maybe better ask you, how you would do it.....
and learn from what you wrote.....
so i can ask questions why yours works.....???

but since forums most of the time do not help when you are not trying yourself, i shared honestly where i was and what i was doing in the hopes i find someone, who was willing and capable of helping me.....

i will try what you mentioned and will see how i can do what you give me as hints.....
when ready i will share my findings or questions again......

thank you again for taking the time to help me.....
i realy apreciate it......

if you do agree with a Skype or teamviewer session i will pm you my details.....
please let me know.....???
maybe we can save a lot of time and writing, ... me can better hear then read....

wil keep you posted....
thx......user added image


*
The Universe is larger then you ever can think, But smaller then the size of your imagination.

all are welcome at www.ieoie.nl
# 11 07-10-2013 , 01:35 PM
ieoie's Avatar
Registered User
Join Date: Aug 2007
Location: The Netherlands
Posts: 88
did get the frames realtime in the panel....
switching the color to green is a bit tougher.....
;-)


thank you.....
will update when my toughts are empty and it is still not as it should.....;-)


*
The Universe is larger then you ever can think, But smaller then the size of your imagination.

all are welcome at www.ieoie.nl
# 12 07-10-2013 , 09:12 PM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
Hey no problem, I jumped in and started learning MEL the same way, by trying to create something practical. Also check your private messages.


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::
# 13 07-10-2013 , 09:20 PM
ieoie's Avatar
Registered User
Join Date: Aug 2007
Location: The Netherlands
Posts: 88

Got Them working.....;-)

global proc RT_Check ()
{
//......... expres. on locator runs every frame this procedure... "RT_Check ()".............//
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 ;


//.................................................. ........
//........ Adding Realtime elements to RTC_Display........//
//.................................................. ........
intField -e -v $curFrame my_realtimeCurrentFrame;
intField -e -v $prevFrame my_realtimePreviousFrame;


//.................................................. ........
//........ Tracking the state of the Atribute.............//
//.................................................. ........
int $trackCheck01 = `getAttr pSphere1.inP01` ;
int $trackCheck02 = `getAttr pSphere2.inP01` ;
// print ($trackCheck01 + " Visible Status \n") ;


//.................................................. ........
//........ What to do whith what state....................//
//.................................................. ........
if ( $trackCheck01 == 1 )
{
textField -e -bgc 0 1 0 -tx "On" colorFlash01 ;
// print "Green \n" ;
// ........... switchMoment1 ($curFrame, $prevFrame, $trackCheck01);
}
else
{
textField -e -bgc 1 0 0 -tx "Off" colorFlash01 ;
// print "Red \n" ;
}
print "\n" ;

//............................................
if ( $trackCheck02 == 1 )
{
textField -e -bgc 0 1 0 -tx "On" colorFlash02 ;
// print "Green \n" ;
// switchMoment2 ($curFrame, $prevFrame, $trackCheck01);
}
else
{
textField -e -bgc 1 0 0 -tx "Off" colorFlash02 ;
// print "Red \n" ;
}
print "\n" ;
}


//.................................................. ....................
//....... Fetching the specific frame the switch changes state..........
//.................................................. ....................

all is working as it should..... very cool.....;-)
thank you....

the final script will have 64 predefined input channels, so the names of the sphere1 and sphere2 will be replaced by the 64 inputs in the final script.......
writing a specific line for each object i do not mind......
if you know a better way to do this.....
feel free to share....;-)

the next step for me is filling in the starting and end frame of the change in state...

you advise to query the keyframe of a attribute

the thing with this script is.....
it will be used in a running Maya environment, meaning that the mocap device will controll the rig, and a second input device will trigger the predefined traxeditor clip
we are going to connect Maya's viewport to the projector we use at the show........

so now the spheres are keyed, but in the live show they will be triggered from an external source, so that is why i have to fetch the moment the trigger comes in..... and this i am still thinking on how to do.....

any ideas on this one.....???


thats why i am thinking to make a check with the previous frame state....
else maya keeps giving me each frame new start and stop frames, resulting in a animation that every frames is in start position......


so in a sense this next block is the final section to get all info visualized....
then the plan is to connect it to the traxeditor clip in the next step....


Code:
/*
proc switchMoment1 (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 
        { 
        print ($curFrame + " Start Frame \n") ; 
        //string %colRed = `textField -rgb 1 0 0` ;
        }
        
		if ( $trackCheck01 == 1 ) 
        { 
        print "STOP Non-Active \n" ;
        } 
        else 
        { 
        print ($curFrame + "STOP Start Frame \n") ; 
        //string %colRed = `textField -rgb 1 0 0` ;
        }
}
*/
//------------------------------------------------------------------
// -------------------------------------------- MAKING PRIME MENU --
//------------------------------------------------------------------
proc RTC_Display ()
{
if (`window -exists flow_toolsUI`)
deleteUI flow_toolsUI;

float $startFrame = `currentTime -q`;
float $prevFrame = $startFrame - 1 ;
string $animLength1 = "5 fr" ;
string $animLength2 = "10 fr" ;
string $animLength3 = "15 fr" ;
string $animLength4 = "20 fr" ;

window
-width 300
-sizeable false
-t "FrameTools"
-iconName "ieoie Tools"
-mxb off
flow_toolsUI;

rowColumnLayout -numberOfColumns 1
-columnWidth 1 300
columnLayout;
text "";
text "Real-Time On/Off Check";
text " ";
setParent ..;

rowColumnLayout -numberOfColumns 2
-columnWidth 1 150
-columnWidth 2 150

columnLayout;
text "Current Frame";
text "Previous Frame";
intField -editable true my_realtimeCurrentFrame ;
intField -editable true my_realtimePreviousFrame ;
setParent ..;
text " ";
setParent ..;

frameLayout -w 400 -h 500 -label "Tracked Object Stats";

string $objectsIntrace1 = `rowColumnLayout -numberOfColumns 5
-columnWidth 1 100
-columnWidth 2 50
-columnWidth 3 50
-columnWidth 4 50
-columnWidth 5 50`;

text " ";
text "Start";
text "Length";
text "Stop";
text " " ;

text -l "Tracked Object 001";
intField -editable true inP1_CF ; //... here comes the start frame of the animation
textField -it $animLength2 -editable false animL1 ;
intField -editable true inP2_CF ; //... here comes the end frame of the animation
textField -editable true -bgc 0 1 0 colorFlash01 ;

text -l "Tracked Object 002";
intField -editable true inP3_CF ;
textField -it $animLength1 -editable false animL2 ;
intField -editable true inP4_CF ;
textField -editable true -bgc 0 1 0 colorFlash02 ;

setParent ..;
setParent ..;

text "Testing real-time notification";

showWindow flow_toolsUI;
}

RTC_Display ;


*
The Universe is larger then you ever can think, But smaller then the size of your imagination.

all are welcome at www.ieoie.nl
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads