Forum

#1 2016-10-20 14:45:49

ChienLoutre
Member

python : set and setinheritedattr

Hi !  I'm Maurin, a student at Mopa, in Arles.

I'm trying to modify attributes via Python, but i'm facing several issues.
Here is my script, i put the issues i got in commentaries.

# ----------------- SCRIPT ----------------------

from guerilla import Modifier, pynode

rPass = pynode('RenderPass')
someRefNode = pynode('RandomRefNode')

with Modifier() as mod:

    # These 3 work perfectly
    rPass.EnableDepthOfField.set(False)
    rPass.DisableMotionBlur.set(True)
    someRefNode.setinheritedattr('Referenceable',False, False)

    # However, this does not work
    rPass.setinheritedattr(False,False)
   
    # This one works, but only if "override" button is checked,
    # and I'm not able to modify it (uncheked by default)
    rPass.Referenceable.set(False)

# ----------------- SCRIPT ----------------------

How should I write this ?

Thank you very much !


Maurin, MoPA student

Offline

 

#2 2016-10-20 22:17:30

Ben
Guerilla dev, the guy to hug

Re: python : set and setinheritedattr

Hi ChienLoutre,

What a name! smile
That's unfortunate, the setinheritedattr method isn't properly binded for RenderPasses. Being as sugar for createplug, you can do the following instead:

Code:

from guerilla import Modifier, pynode
import guerilla

rPass = pynode('RenderPass')
someRefNode = pynode('NewNode')

with Modifier() as mod:

    # These 3 work perfectly
    rPass.EnableDepthOfField.set(False)
    rPass.DisableMotionBlur.set(True)
    someRefNode.setinheritedattr('Referenceable',False, False)

    # create the plug using createplug
    # createplug throws an exception if the plug already exists, so try/except is recommended
    try:
        mod.createplug (rPass, 'Referenceable', plugType='Plug', dataType='bool', flags=guerilla.Plug.Dynamic)
    except:
        pass
    # So we can set it to False now
    rPass.Referenceable.set(False)

That should work fine now.

Ben


Benjamin 'Ben' Legros
Guerilla developer
http://www.guerillarender.com

Offline

 

#3 2016-10-21 10:12:26

ChienLoutre
Member

Re: python : set and setinheritedattr

Thanks !
Works like a charm !


Maurin, MoPA student

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2008 PunBB