PDA

View Full Version : AEtemplate and dynamic controls dimming


powernemo
01-17-2008, 08:25 AM
Hello all,
i'm writing an AETemplate file and i have a question about dimming the other controls:
i have this piece of code


editorTemplate -beginLayout "Coating" -collapse 0;
editorTemplate -addSeparator;
editorTemplate -callCustom "AECoatingModeNew" "AECoatingModeReplace" CoatingMode";
editorTemplate -addSeparator;
editorTemplate -l "Thickness [nm]" -addControl "Thickness";
editorTemplate -l "Coat Weight" -addControl "Coat_Weight";
editorTemplate -l "Interlayer Spacing[nm]" -addControl "InterLayer_Spacing";
editorTemplate -endLayout;


global proc AECoatingModeNew(string $CoatingMode)
{
attrEnumOptionMenuGrp
-l "Coating Mode"
-at $CoatingMode
-ei 0 "Thin Surface Coat"
-ei 1 "Bi-Layering";
}

global proc AECoatingModeReplace (string $CoatingMode)
{attrEnumOptionMenuGrp -ex -at $CoatingMode CoatingMode;}


well, as i select from the Option box i wish to update the Attribute Editor dimming a textbox like this:


global proc AECoatingMode ( string $nodeName )
{
if ((getAttr ($nodeName+".CoatingMode")))
{
editorTemplate -dimControl $nodeName "InterLayer_Spacing" false;
}
else
{
editorTemplate -dimControl $nodeName "InterLayer_Spacing" true;
}
}

someone can helps?

Thnx :)

goleafsgo
01-17-2008, 02:45 PM
What you could do is create an attributeChanged script job which is parented to the UI element that you are monitoring.

In AECoatingModeNew you would create the scriptJob like this:

string $MyControlName = `attrEnumOptionMenuGrp
-l "Coating Mode"
-at $CoatingMode
-ei 0 "Thin Surface Coat"
-ei 1 "Bi-Layering"1;

global int $MyScriptJobId;

string $cmd = ("MyCallback \"" + $nodeName + "\"");
$MyScriptJobId = `scriptJob -parent $MyControlName
-replacePrevious
-attributeChange $attrName
$cmd`;


So now you would have a scriptJob monitoring the attribute and it will be attached to the control so if the UI element gets deleted it should also kill the scriptJob.

Then in "AECoatingModeReplace " you attach the script job to the new node.

global int $MyScriptJobId;
scriptJob -kill $MyScriptJobId;

string $cmd = ("MyCallback \"" + $nodeName + "\"");
$MyScriptJobId = `scriptJob -parent $MyControlName
-replacePrevious
-attributeChange $attrName
$cmd`;


Then you just need to implement "MyCallback"...actually that would be your AECoatingMode proc that you have.

Hope that at least gets you started.

powernemo
01-17-2008, 07:46 PM
Thanks a lot for your reply goleafsgo that was quite helpful,
i messed a little with the code implementing it on my template.
For now though it's half developed, I've made only the first part and i'm able from there to call the dimming function but i can't use it cause i don't have the node name.
I dunno how to obtain it, i have this


global proc AET2S_CoatingTemplate( string $nodeName )
{*
...
editorTemplate -beginLayout "Coating" -collapse 0;
editorTemplate -addSeparator;
editorTemplate -callCustom "AECoatingModeNew" "AECoatingModeReplace" **"CoatingMode";
editorTemplate -addSeparator;
editorTemplate -l "Thickness [nm]" -addControl "Thickness";
editorTemplate -l "Coat Weight" -addControl "Coat_Weight";
editorTemplate -l "Interlayer Spacing[nm]" -addControl "InterLayer_Spacing";
editorTemplate -endLayout;

...
}

i tried many cases

*) here 'print $nodeName' returns 'T2S_Coating1' (the name of the node)
**)but if i check here i got "T2S_Coating.CoatingMode" and this value is passed to AECoatingModeNew, passing a empty string as argument "" (instead than "CoatingMode") gives me "T2S_Coating1." (mind the final "." )

how i can get the node name only?

powernemo
01-18-2008, 09:43 AM
I found an alternate solution that works:buttrock:
//-----------------------CREATION
global proc AECoatingModeNew(string $attrName)
{
optionMenu -label "Coating Method " -cc ("AECoatingModeChange \"" + $attrName + "\"") AECoatingModeGRP;
menuItem -da 0 -l "Thin Surface Coat";
menuItem -da 1 -l "Bi-Layering";

setUITemplate -ppt;
AECoatingModeReplace( $attrName );


}
//-----------------------REPLACING
global proc AECoatingModeReplace (string $attrName)
{
optionMenu -e -cc ("AECoatingModeChange \"" + $attrName + "\"") AECoatingModeGRP;
connectControl AECoatingModeGRP $attrName;
AECoatingModeChange($attrName);

}

//-----------------------CALLBACK
global proc AECoatingModeChange ( string $nodeName )
{
int $opt = `getAttr $nodeName`;
string $node[];
tokenize $nodeName "." $node;

switch ($opt){

case 0:
{
editorTemplate -dimControl $node[0] "InterLayer_Spacing" false;
break;
}
case 1:
{
editorTemplate -dimControl $node[0] "InterLayer_Spacing" true;
break;
}
}

}

and here i have as usual

global proc AET2S_CoatingTemplate( string $nodeName )
{
...
editorTemplate -beginLayout "Coating" -collapse 0;
editorTemplate -addSeparator;
editorTemplate -callCustom "AECoatingModeNew" "AECoatingModeReplace" ("CoatingMode"
editorTemplate -addSeparator;
editorTemplate -l "Thickness [nm]" -addControl "Thickness";
editorTemplate -l "Coat Weight" -addControl "Coat_Weight";
editorTemplate -l "Interlayer Spacing[nm]" -addControl "InterLayer_Spacing";
editorTemplate -endLayout;

...
}

the rest was quite easy

CGTalk Moderation
01-18-2008, 09:43 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.