View Full Version : Help Passing Variable

06 June 2007, 01:14 AM
I need some help passing $filename variable into createN proc.
Or should I use fileDialog instead of fileBrowser? I'm guessing you need to link to a button -c ("") etc Any help? Thanks!

//?? string $result = `fileDialog -dm "*.jpg"`

$win = `window -title "OpenFile v1.0"`;

global proc int onOpen(string $filename, string $type)
return true;

global proc createN()
string $lambertShader = "lambertshader";
string $imageNodeName = "imagefilename";
shadingNode -n $lambertShader -asShader lambert;
string $innOC = $imageNodeName + ".outColor";
string $lsC = $lambertShader + ".color";
$fileNode = `createNode file -n $imageNodeName`;
//$filename = "F:/Blah/image.jpg";
setAttr ($fileNode + ".ftn") -type "string" $filename;
connectAttr -f $innOC $lsC;

global proc browseTF()
fileBrowser( "onOpen", "Open", "", 0 );

frameLayout -w 150 -cll true OpenFile;
text - l "1. Open File";
button -c browseTF -l "Browse";
button -c createN -l "Create";


06 June 2007, 07:17 AM

basically what u have to do is to use only one button , which will open fileBrowserDialog,
fileBrowserDialog will fetch the filename and pass on to subsequent function,

or else, make two buttons,
make a textField, and let fileBrowserDialog pass the filename to textField,

so other function attached with other button will read the path from textField and do needed,


global proc browseDir(){
fileBrowserDialog -m 4 -fc "selectDirPath" -an "Browse Directory";

global proc selectDirPath(string $dirname, string $fileType ){
global string $pbdir;
textField -e -text $dirname txf1;

hope this helps,


06 June 2007, 08:56 AM
Thank you, I used fileDialog instead with a text control.

if(`window -exists IFwinUI`)
deleteUI IFwinUI;
$win = `window -title "BrowseToImage" IFwinUI`;

global proc createN()
string $filename = `fileDialog -dm "*.jpg"`; //Opens File Browser
global string $pbdir;
text -e -label $filename textL;

global proc printN()
string $dirFile = `text -q -l "textL"`;
print $dirFile;

formLayout uiFL;

button -w 100 -c createN -l "Open Image ..." openI;
button -w 100 -c printN -l "Print ..." printI;
text -vis 1 -label "" -al "left" textL;
setParent ..;

formLayout -edit
-af openI "top" 0
-af openI "left" 0
-af printI "top" 25
-af printI "left" 0
-af textL "top" 2
-af textL "left" 105

showWindow IFwinUI;

CGTalk Moderation
06 June 2007, 08:56 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.