View Full Version : refresh UI during a running script

03 March 2009, 01:05 PM
I'm using a python script to create render layers, put objects selected in them, and at the end I have to change the shaders of objects in the different render layers. By hand it's working well, but within the script it's not working at all. Render layers are created but the shaders are not changed. If I cut the script in two parts, the first to create render layers and the second one to change the shaders it's ok if I launch the first and then the second one when the first one is finished, but not within one script.
I think it's because the render layers window is not refreshed during the execution of the script, but can I force the refresh during the running script?
Or is there a way to change by script the shader of a specific object in a specific render layer?
Thanks a lot,

03 March 2009, 03:28 PM
use the refresh command :)

03 March 2009, 04:38 PM
unfortunately refresh isn't working...
this is my code

def f1():'head_HR',r=1)
sel =
for l in range(1,9):
nameRL=('RL_%d' %l)
mc.createRenderLayer (sel, name=nameRL, noRecurse=1)

def f2():
for i in range(1,9):
nameRL = 'RL_%d' %i
mel.eval('layerEditorLayerButtonSelect 0 ' + nameRL)'head_HR', r=1)
if i==5:
mc.sets(forceElement='dgs_material1SG' )
mc.sets(forceElement='importedMaterial_blackhole_shdSG' )

mc.refresh(cv=0, f=1)
for j in range (1,100): print j

#during the loop after the refresh command I can see that the render layers window is not refreshed at all :(

Do you see what's wrong?

03 March 2009, 04:47 PM
I've never tried refresh in a python script. I have had some some success using eval(), as it calls the script differently.

03 March 2009, 05:40 PM
I don't believe there is any way to easily force the Render Layers panel to refresh. You would need to have a look at how the Render Layers panel is setup and hope to find a method that you can invoke on it that will update its elements.

The refresh command only controls the viewports. Calling the refresh after having changed the shader for an object in a given render layer should still update in the viewport if the change was made in the active render layer.

CGTalk Moderation
03 March 2009, 05:40 PM
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.