0
$\begingroup$

I am trying to turn passes on and off via python. But I can't find out how to change the cryptomatte settings:

this is what the info panel shows when I click on Cryptomatte - Object:

bpy.context.scene.use_pass_crypto_object = True

it returns this:

AttributeError: 'Scene' object has no attribute 'use_pass_crypto_object'

so I tried each of these lines, but none of them work:

bpy.context.scene.view_layers["View Layer"].use_pass_crypto_object = False

bpy.context.scene.render.use_pass_crypto_object = False

bpy.context.scene.use_pass_crypto_object = False

This one doesnt throw an error, but also does nothing, and it is not a UI refresh issue:

bpy.context.scene.cycles.pass_crypto_accurate = False

Does somebody know how to access it? Thanks!

$\endgroup$
1
$\begingroup$

View the UI source

In User Preferences > Interface > Display turn on developer extras. Sounds like you already have. When the path in button hover is dodgy, if available click view source on a field of interest.

In this case it opens addons/cycles/ui.py in text editor at or around the CryptoMatte draw panel where this leaps out

cycles_view_layer = context.view_layer.cycles

Off to the python console:

>>> cycles_view_layer
bpy.data.scenes['Scene']...CyclesRenderLayerSettings

>>> cycles_view_layer.use_pass_crypto_
                                      asset
                                      material
                                      object
>>> cycles_view_layer.use_pass_crypto_object
True

>>> cycles_view_layer.pass_crypto_
                                  accurate
                                  depth
>>> cycles_view_layer.pass_crypto_depth
6

>>> cycles_view_layer.pass_crypto_depth = 10
>>> 

can put in accurate mode with

cycles_view_layer.pass_crypto_accurate = True

Some more fiddling, the property is displayed as belonging to scene

>>> cycles_view_layer.id_data
bpy.data.scenes['Scene']

>>> C.scene.view_layers['RenderLayer'].cycles
bpy.data.scenes['Scene']...CyclesRenderLayerSettings

>>> cycles_view_layer
bpy.data.scenes['Scene']...CyclesRenderLayerSettings

>>> C.scene.view_layers['RenderLayer'].cycles is cycles_view_layer
False

>>> C.scene.view_layers['RenderLayer'].cycles == cycles_view_layer
True
$\endgroup$
  • $\begingroup$ Thanks batFINGER, this works! I will add this solution to my post $\endgroup$ – cookiemonsterandthegirls Jul 23 at 15:44
0
$\begingroup$

solution from batFinger:

from bpy import context
cycles_view_layer = context.view_layer.cycles
cycles_view_layer.use_pass_crypto_object=False

thanks!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.