[Mel] Waiting for part of script to finish?

Hello.

Im writing a script that will automatically do all of the following at once [ul]
[li]create a spotlight, [/li][li]create the RSL shadow attributes needed like deep shadows[/li][li]put a variable in the shadowMap name so i can manage this in another place[/li][li]attach a rsl uberLight shader to it and a custom viewport visualizer[/li][li]move it to 0 10 0[/li][li]look through it[/li][/ul]

I am very close to doing this - however! I have to execute the code in two stages to get the RSL attributes to attach to the lightAttributes of the spotlight.

I want to do it in one command. Probably an if statement?

I’m using a proc

AE_reselectTabIndex

that was included with 3delight which make me able to select the fourth tab in the AE and then i can get the name of it with the maya proc $gAECurrentTab and then filter it with startString.

However, when I run this all at once it doesnt work and when I try to print the result of $currrentNode i just get $currentNode unless like I said I execute the the second part after the first :?: I am probably going to have a lot of lights so I need it to be dynamic and depend on this variable. I figure that if I have more than 9 lights i can run an alternate version of the script that does

$currentNode = startString($gAECurrentTab, [B]21[/B]); 

instead of 20.

I’ve done a lot of research, been working on it for 2 days now. Ive tried return arguments, eval deferred, timerX, splitting it up into (global) procs etc but they arent working.

Any help is appreciated. Im sure this is a common question.:nod:


defaultSpotLight(1.5, 1,1,1, 0, 40, 0, 0, 0, 0,0,0, 1, 0) ;
DL_shaderAssignmentPanelCreateNewAttribsNode delightLightAttribs object;
dR_movePress;
move -r -os -wd 0 10 0 ;
AE_reselectTabIndex(4);
////////////////////////////////////
//////////
$currentNode = startString($gAECurrentTab, 20); 
//////////

DLA_generateShadowMapsCreateAttr ($currentNode);
DLA_shadowMapNameCreateAttr($currentNode);
DLA_shadowMapResolutionCreateAttr($currentNode);
DLA_shadowMapShadingRateCreateAttr($currentNode);
DLA_shadowDepthFilterCreateAttr($currentNode);
DLA_shadowMapTypeCreateAttr($currentNode);
DLA_shadowMapPixelSamplesCreateAttr($currentNode);
DLA_nearClipPlaneCreateAttr($currentNode);
DLA_farClipPlaneCreateAttr($currentNode);
DLA_emitPhotonsCreateAttr($currentNode);
DLA_generateWithMotionBlurCreateAttr($currentNode);
DLA_generateCubeShadowMapCreateAttr($currentNode);
DLA_volumeInterpretationCreateAttr($currentNode);
DLA_transformationBlurCreateAttr($currentNode);
setAttr ($currentNode +".generateShadowMaps") 1;
setAttr ($currentNode +".shadowMapType") 6;
//lookThru `ls -sl`;

Maybe try tossing in a refresh command? Seems like that AE reselect tab function does something in the UI which won’t update until the script has finished.

I can’t remember the solution to this. I think it may be that you need to put the latter part of your script in an evalDeferred or a ScriptJob “onIdle”. So that the Attribute Editor has a chance to do it’s update stuff. Also, the attribute editor needs to actually be open for this stuff to work. I assume that is a given.