Collection show

Hi all

As i recently migrate definetely to 2.9, i’m rewriting my small script to export the scene from blender to unity3D.

What i want to do is export everything ( even in hidden collections ) EXCEPT:

  • objects with the name starting with a . or a _
  • objects that are linked

My problem come from collections.

I got a cube in a collection. This collection is hidden and i cannot unhide it in python.

Here’s what i do:

import bpy.ops
import bpy


# 1st of all show/activate all collections
for coll in bpy.data.collections:
    print(coll.name)
    print(coll.hide_render)
    print(coll.hide_select)
    coll.hide_render = False
    coll.hide_select = False


# deselect everything
bpy.ops.object.select_all(action='DESELECT')

# then parse all objects list.
# activate the current one and only inactivate it if is has a '_' or '.' ath the start of its name.
# also inactivate it if it's a linked object :-)
for obj in bpy.data.objects:
    obj.select_set(True)
    if obj.name[0] in '_.':
        obj.select_set(False)

Note am a dumb ass in python XD so please be gentle and give me simple answers :stuck_out_tongue:
Thanks in advance and happy blending !

I reply to myself…

Strangely this does nothing in blender, but the object in the hidden collection is selected and then exported to unity3D.

Then i got what i need.

I got another question though. About linked objects:

In 2.79 we could test an object is linked with:

            the_obj = bpy.data.objects[obj.name]
            if the_obj.library != None:
                obj.select = False 

This do not work in 2.9

Any help please ?

Thanks and happy blending !

Okay… i’m definetely too stoopid :confused:

Those 3 lines work fine is i replace the obj.select with obj.select_set(False)

:slight_smile:

Now my script works fine and i will update the old topic talking about this:

Happy blending !