Disable an object from the viewlayer

Hi

How can I disable an object from the current view layer (the computer screen icon) ?

C.object.hide_viewport=True only hides it in the viewport. I would like to disable the objects in the viewlayer because it seems like they are still processed if they are enabled in the View Layer but hidden from it.

The ui action produces almost the same Python output , so that is not very useful.

blender_xhpSkk92D5

I found a solution after digging further. Here is how to do it in case someone else needs it too.

C.view_layer.objects[NAME_OF_THE_OBJECT].hide_viewport=True