PDA

View Full Version : refresh UI during a running script


kzax
03-19-2009, 02:05 PM
Hi,
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,
Philippe.

HapG
03-19-2009, 04:28 PM
use the refresh command :)

kzax
03-19-2009, 05:38 PM
unfortunately refresh isn't working...
this is my code

def f1():
mc.select('head_HR',r=1)
sel = mc.ls(sl=1)
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)
mc.select('head_HR', r=1)
if i==5:
mc.sets(forceElement='dgs_material1SG' )
else:
mc.sets(forceElement='importedMaterial_blackhole_shdSG' )
mc.select(clear=1)

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

#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?

HapG
03-19-2009, 05: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.

Keilun
03-19-2009, 06: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-19-2009, 06: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.