Pause/Resume a script?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  04 April 2006
Pause/Resume a script?

Hi everyone,

I've been working on this script for setting up a character rig. At one point a new window is created within a procedure which requires the use of a string variable declared within the same procedure. The problem is, the window pops up and the procedure keeps running, as it's called by a button command from the original script UI. So the string the window needs not only no longer exists by the time the user interacts with the new window, but the changes the new pop-up window is supposed to make are obsolete, as it is supposed to effect objects before the procedure finishes.

So is there a way to pause a preocedure, or stop it from evaluating until the pop-up window is closed?

an example...
global proc test()
 {
 string $neededString = "needed";
 float $neededFloat;
 
 string $newWindow = `window -title "window1"`;
 columnLayout;
 floatSliderGrp -label "size"
 -field true
 -value 0
 -minValue -10 -maxValue 10
 rowLayout;
 button -label "scale now" -command "$neededFloat = `floatSliderGrp -q -value myWin`; setAttr ($needeString + \".scale\") $neededFloat $neededFloat $neededFloat" myWin;
 
  
 showWindow $newWindow;
 
 }


clicking the button results in...
// Error: $neededFloat = `floatSliderGrp -q -value myWin`; setAttr ($needeString + ".scale") $neededFloat $neededFloat $neededFloat; //
 // Error: "$needeString" is an undeclared variable. //
 


does anyone know how to fix this?
 
  04 April 2006
You should probably add a callback to your UI slider and then in the callback do whatever you need to do. But, no...the string you are declaring is local to the proc so what you have isn't going to work.

Looking at what you have there I think the attrFieldSliderGrp might be a control that you could use...try this example:


 window -title "Attr Field Slider Groups";
 		string $objName[] = `sphere`;
 		columnLayout;
 		attrFieldSliderGrp -min -10.0 -max 10.0 -at ($objName[0]+".tx");
 	showWindow;
 
 
  04 April 2006
Thanks for the info,

How would I go about creating a callback?
 
  04 April 2006
I think this is an issue regarding variable scope. In your example, since $neededString is declared within the bloc of a procedure, it exists only within the scope of that proc. If you turn your proc into one that returns a string value, however, and input the return value into a variable which exists outside your proc, I think you will get what you're looking for. Here is a modified example:
global proc string test()
{
string $neededString = "needed";
float $neededFloat;

string $newWindow = `window -title "window1"`;
columnLayout;
floatSliderGrp -label "size"
-field true
-value 0
-minValue -10 -maxValue 10
rowLayout;
button -label "scale now" -command "$neededFloat = `floatSliderGrp -q -value myWin`; setAttr ($neededString + \".scale\") $neededFloat $neededFloat $neededFloat" myWin;


showWindow $newWindow;
return $neededString;
};
float $neededFloat;
string $neededString;
$neededString = test();
 
  04 April 2006
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 05:36 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.