How to do this?
I've tried
bpy.context.view_layer.layer_collection["my_collection"].exclude = False
and
bpy.context.layer_collection["my_collection"].exclude = False
and tried looping through collections:
def execute(self, context):
collections = get_viewport_ordered_collections(bpy.context)
for c in collections:
if c.name == "my_collection":
...
but the error says get_viewport_ordered_collections is not defined
get('your_collection_name')instead to avoid our famous index error. Note that using the data block reference (bpy.data.collections...) might cause issues if the collection is not part of the current scene. Alsobpy.contextin your q example should be replaced bycontextwhich is already passed to the method. – brockmann Aug 04 '21 at 10:26