Isotropix Forums

Adding AOVs while render is running

Clarisse Scripting related topics

Adding AOVs while render is running

Unread postby DarkNemos » Fri Jun 15, 2018 5:31 pm

Hi, i have a script that adds AOVs based on a default list and light groups used in the current layer. It works great if i dont have the render currently running. If the render is being evaluated i cannot set the value count to 0. It just keeps what ever it had before it started rendering.

Is there a better way of doing this? Or perhaps is there a way through python to pause and resume the render while i am doing the changes?

Also what would be a proper way to remove an AOV in a specific array spot? Lets say i have 10 passes and i want to remove the 6th one, how would i go and change the array sizes?

When doing this through they UI i get in the log ix.cmds.BatchCommand() and i cannot see how it is being done exactly so most of the information i have here is collected through the forum and some guess work.

Below is a sample of the code that works fine if the render is not running and fails if the render is active. Please select a layer_3d and run it:

Code: Select all
# just an example of some default passes i could potentially want
defaultAOVs = ['pbr_diffuse_transmission', 'pbr_diffuse_reflection', 'pbr_glossy_transmission', 'pbr_glossy_reflection']

def addAOV(aovName):
    # adding one aov
    old_value_count = aov_list.get_value_count()
    aov_list.set_value_count(old_value_count + 1)
    enabled_aov_list.set_value_count(old_value_count + 1)
    aov_blend_override_list.set_value_count(old_value_count + 1)
    aov_list.set_string(aovName, old_value_count)
    enabled_aov_list.set_bool(True, old_value_count)
    aov_blend_override_list.set_long(ix.api.OfChannelManager.AOVBLENDINGMODE_INVALID, old_value_count)

selection = [ix.selection[0]]

for layer_3d in selection:
 
    # grabs the 3 arrays
    aov_list = layer_3d.get_attribute("selected_aov_list")
    enabled_aov_list = layer_3d.get_attribute("enabled_aov_list")
    aov_blend_override_list = layer_3d.get_attribute("aov_blend_override_list")
   
    # resetting array sizes in order to rebuild the passes
    aov_list.set_value_count(0)
    enabled_aov_list.set_value_count(0)
    aov_blend_override_list.set_value_count(0)
   
    if aov_list.get_value_count() != 0:
   
        print 'This should be zero but instead its: %d' % aov_list.get_value_count()
    else:
        print 'Its zero so it works fine'

   
    for i in defaultAOVs:
        addAOV(i)


Please let me know.

Thanks!
DarkNemos
 
Posts: 4
Joined: Sun Nov 19, 2017 4:16 am

Re: Adding AOVs while render is running

Unread postby bvaldes » Mon Jun 18, 2018 10:38 am

Hi,

We found the issue. Even if the functions you used works great, there were an issue about the dirtiness propagation. So you have to use commands (function starting with ix.cmds...).

This is the fixed script:

python code

# just an example of some default passes i could potentially want
defaultAOVs = ['pbr_diffuse_transmission', 'pbr_diffuse_reflection', 'pbr_glossy_transmission', 'pbr_glossy_reflection']

def addAOV(aovName):
# adding one aov
ix.cmds.AddValues([str(aov_list)], [str(aovName)])
ix.cmds.AddValues([str(enabled_aov_list)], ["1"])
ix.cmds.AddValues([str(aov_blend_override_list)], [str(ix.api.OfChannelManager.AOVBLENDINGMODE_INVALID)])

selection = [ix.selection[0]]

for layer_3d in selection:

# grabs the 3 arrays
aov_list = layer_3d.get_attribute("selected_aov_list")
enabled_aov_list = layer_3d.get_attribute("enabled_aov_list")
aov_blend_override_list = layer_3d.get_attribute("aov_blend_override_list")

# resetting array sizes in order to rebuild the passes
ix.cmds.SetValueCount([
str(aov_list),
str(enabled_aov_list),
str(aov_blend_override_list)
], [0, 0, 0])

if aov_list.get_value_count() != 0:

print 'This should be zero but instead its: %d' % aov_list.get_value_count()
else:
print 'Its zero so it works fine'


for i in defaultAOVs:
addAOV(i)

That was hard to find, hopefully the engineers were there!

Best regards
Benoit VALDES
Isotropix
Clarisse QA
User avatar
bvaldes
 
Posts: 254
Joined: Mon Sep 26, 2016 11:44 am

Re: Adding AOVs while render is running

Unread postby DarkNemos » Tue Jun 19, 2018 4:41 pm

Hey bvaldes,

It works like a charm! Thank you for your help!

Cheers!
DarkNemos
 
Posts: 4
Joined: Sun Nov 19, 2017 4:16 am


Return to Scripting