I’m sorry this was my bad. Actually i was declaring the variable after the infieldgrp generation in coding. that’s why i was getting the error.
I have to declare the variable at the very beginning of the code and it will run like a charm.
so the code looks like:
//declare the variable first
int $getoccsampl = `getAttr mibOccTexture.samples`;
float $getoccspread = `getAttr mibOccTexture.spread`;
float $getoccMaxD = `getAttr mibOccTexture.max_distance`;
//then generate the infield or floatfield
if ( `window -exists Test` ) {deleteUI OccDepthvalue;}
window -s no -te 110 -title "Test Window" Test;
if (`windowPref -exists OccDepthvalue`) windowPref -remove OccDepthvalue;
columnLayout;
rowLayout -numberOfColumns 4 -columnWidth3 0 0 0;
columnLayout center;
intFieldGrp -nf 1 -cw 1 110 -cat 10 left 1 -cat 2 both 5 -l "Occlusion Samples :" -v1 $getoccsampl -cl2 right left OccSmpl;
separator -style "none" -h 3;
floatFieldGrp -nf 1 -cw 1 110 -cat 10 left 1 -cat 2 both 5 -l "Maximum Distance :" -v1 $getoccspread -cl2 right left OccMD;
separator -style "none" -h 3;
floatFieldGrp -nf 1 -cw 1 110 -cat 10 left 1 -cat 2 both 5 -l "Sprade :" -v1 $getoccMaxD -cl2 right left OccSprd;
separator -style "none" -h 10;
setParent..;
button -label "Accept" -w 50 -h 50 -command "setOccValue()";
setParent..;
setParent..;
//command for the accept button.
global proc setOccValue()
{
int $OccSample = `intFieldGrp -q -v1 OccSmpl`;
setAttr "mibOccTexture.samples" $OccSample;
float $OccMaxDist = `floatFieldGrp -q -v1 OccMD`;
setAttr "mibOccTexture.spread" $OccMaxDist;
float $OccSprad = `floatFieldGrp -q -v1 OccSprd`;
setAttr "mibOccTexture.max_distance" $OccSprad;
}
showWindow;
But now i’m having another problem. If the mibOccTexture dosen’t exist then the code doesn’t run at all. and gives me the error
"No object matches name: mibOccTexture.samples "
Now how to fix this, at-least if the ‘mibOccTexture.samples’ doesn’t exist then i should get a confirm dialog saying that the texture doesn’t exist.So How to get that confirm dialog box? 