PDA

View Full Version : UI issues in global procs


swardson
01-01-2005, 11:48 PM
Hey all,

I found this fun little script for saving a list of fileTextures to a text doc. it works great but I wanted to add a UI for inputing the filename and write path. I am having trouble passing the value of the textFieldGrp (the text in the field) to the procedure for listing the file textures. Could you all take a look at this and hopefully see some stupid mistake I am making. Thanks all

Brad

global proc printTextures()
{
window
-title "Print List of File Textures to File"
writeWindow;

columnLayout;
string $fileName = `textFieldGrp -label "/filePath/fileName" -text "/Users/Brad/Desktop/"`;

button -label "Write File" -command "listFileTextures($fileName)";

showWindow writeWindow;

}

global proc listFileTextures(string $fileName)
{
int $fileId = fopen ($fileName, "w");

string $textures[] = `listConnections defaultTextureList1`;

for ($tex in $textures) {

string $fileTex = ($tex +".fileTextureName");

if (`objExists $fileTex`) {

print (`getAttr $fileTex` + "\n");

fprint ($fileId, `getAttr $fileTex` + "\n") ;

}
}

fclose $fileId;
deleteUI writeWindow;
}

Buexe
01-02-2005, 02:43 PM
hi musicraker,

try to use global variables for UI elements you want to edit/query. In your example I suggest:

global string $fileName;

$fileName = `textFieldGrp -label "/filePath/fileName" -text "/Users/Brad/Desktop/"`;

Later, you can query the info in another procedure via:
global string $fileName;

string $text = `textFieldGrp -q -text $fileName`;

print ("FileName: " + $text + "\n");

I hope this helps
buexe

swardson
01-02-2005, 10:26 PM
thanks Buexe, your advice works great......I knew it would be something simple like this.... now, how would one do this without having to use global variables.....Just curious of how it would be done. :)

Thanks again Buexe,

Brad

Buexe
01-03-2005, 05:40 AM
To be honest: I don`t know:shrug:
Every control has a "change command" and I use procs to save the values edited by users in optionVariables so when the UI is reopened the old values are restored but this also works with, yeah you guessed right, global variables.
cheers
buexe

CGTalk Moderation
01-20-2006, 07:00 AM
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.