View Full Version : multiple orient constraints

04 April 2003, 06:00 PM
Hey all,

I am trying to write what seemed like it would be a simple script, but I am completely stuck. It's telling me that the object: " " can't be found....

Anybody got any ideas? thanks in advance.


proc to do it lots of times

passed: string $a

this is the text from the textField, name of

the target

performs: performOrientConstraint

orient constrains multiple objects to one


returns: none


global proc zgOrientMany (string $target)


string $sel [] = `ls -sl`;

string $current;

for ($current in $sel)


select -r $current;

select -tgl $target;

performOrientConstraint 0;

orientConstraint -w 1;




A GUI to make life easier

passed: none

performs: GUI window to run zgOrientMany

returns: none


global proc zgGUI ()


string $textfield = "objects";

global string $target = " ";

window -t "Some scripts";


text -l " Orient mulitle objects to a single target ";

text -l " 1. First select all the objects to constrain: ";

text -l " 2. Then type in the name of the target: ";

textField -w 300 $textfield;

textField -q -tx $target;

button -w 300 -l " 3. Then Click this button."

-c "zgOrientMany $target";




//written by zach grachan


04 April 2003, 05:07 AM
The problem is that $target = "" and as this is written it will always = "".

You need to change your button command so that either it or the proc that it calls querries the field for the current value.

1) Querrying the field for the value before building the button does nothing because the field is empty at that point. That window hasn't even drawn yet!

2) And even if there were a value in the field, the $target variable exists within the UI proc's scope, while the button command exists within it's the general scope. Therefore, the value of $target will always be "".

Do this instead. Change your text field call to:

textField -w 300 "zgTargetField";

This gives the field a unique name by which it can be querried later. Yes, you did this, but I'm going with an explicitly unique name here.

Now forget about doing anything else with the field in the UI portion. Instead of trying to pass this info to your OrientMany proc, querry the field from within that proc.

$target = `textField -q -tx "zgTargetField"`;

Also, you might consider a UI that doesn't require typing at all by adding a button to the UI that will load the text field with the name of any selected object. Artist hate typing... well, most do.


CGTalk Moderation
01 January 2006, 10:00 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.