Closed 77Mynameislol77 closed 2 years ago
@jadshep Seems to be because these bits here never actually return anything except false
I fixed this with the following code
def gather_collection_resources(layer_collection, layer_collection_set, object_set, hidden_geo, nonrender_geo, include_this_collection = False):
"""
Recursively gathers the relevant collections and objects for export, starting from a root layer collection.
"include_this_collection" should be false for the root collection, else restoring visibility will cause everything to become visible regardless of stored value.
"""
if not layer_collection.is_visible:
return
# Add collection to set of all included collections
if include_this_collection:
layer_collection_set.add(layer_collection)
# Add all of collection's objects when not hidden in an undesired way
for obj in layer_collection.collection.objects:
if not hidden_geo and obj.hide_viewport:
continue
if not hidden_geo and obj.hide_get():
continue
if not nonrender_geo and obj.hide_render:
continue
object_set.add(obj)
# Recursively gather resources for child collections
for collection in layer_collection.children:
gather_collection_resources(collection, layer_collection_set, object_set, hidden_geo, nonrender_geo, True)
but I'm not sure if this hurts the workflow you intended or something since it basically only cares if the collection is visible or not.
@General-101 Would something like this work?
def gather_collection_resources(layer_collection, layer_collection_set, object_set, hidden_geo, nonrender_geo, include_this_collection = False):
"""
Recursively gathers the relevant collections and objects for export, starting from a root layer collection.
"include_this_collection" should be false for the root collection, else restoring visibility will cause everything to become visible regardless of stored value.
"""
# Don't include anything from collection if exclude
if layer_collection.exclude:
return
# Don't include anything from collection if hidden in an undesired way
if not hidden_geo and not layer_collection.is_visible:
return
if not nonrender_geo and layer_collection.collection.hide_render:
return
# Add collection to set of all included collections
if include_this_collection:
layer_collection_set.add(layer_collection)
# Add all of collection's objects when not hidden in an undesired way
for obj in layer_collection.collection.objects:
if not hidden_geo and obj.hide_viewport:
continue
if not hidden_geo and obj.hide_get():
continue
if not nonrender_geo and obj.hide_render:
continue
object_set.add(obj)
# Recursively gather resources for child collections
for collection in layer_collection.children:
gather_collection_resources(collection, layer_collection_set, object_set, hidden_geo, nonrender_geo, True)
This should filter collections the same way as objects with differentiation between visible/render.
Aight yea that seems to do it. This should be solved now then.
I have included an example blendfile. Just export it as a JMS
Here's the export settings
blendfile.zip