Thank you for your reply, unfortunately it does not fit my needs.
As I wrote, I need to hide a collection in a specific 3d view and not globally.
I need also to do that in a different context.
LayerCollections are tied to the view layer and outliner states- so without the UI already being in that ‘state’ (eg: you are in the specific view and context you need) you cannot modify them because they don’t exist yet.
argh, I was afraid of something like this… although actually I’m trying to work around it by using the context override.
However with the new temp_override method I can’t set the correct screen, while with the old deprecated method I can act on the collections for a specific view but… I have to call another operator which is executed only at the end of my script and I don’t understand why.
This operator actually shuts down the collections in the correct view but it seems to get the collection index completely wrong…