FBX: Enable the Collection exporter feature #105273

Merged
Jesse Yurkovich merged 6 commits from deadpin/blender-addons:fbx-collectionexport into main 2024-04-16 05:13:36 +02:00
Showing only changes of commit c7e36ccaa2 - Show all commits

View File

@ -3615,7 +3615,7 @@ def save(operator, context,
if collection in bpy.data.collections: if collection in bpy.data.collections:
source_collection = bpy.data.collections[collection] source_collection = bpy.data.collections[collection]

Might want to consider whether performing a Collection export from a Collection linked from another file should be supported because a linked Collection can have the same name as a Collection local to the current file (or presumably another Collection linked from another different file).

Currently, exporting from a linked Collection appears to work, but doesn't seem too useful because the Collection's children, export settings and export file path cannot be changed due to being linked from another file.

I don't know if there is a guarantee that bpy.data.collections[collection] will always return a Collection from the current file in preference to a linked Collection with the same name, but it seems like that might be the case from a quick test using the Python Console. So, exporting from a linked Collection with the same name as a local Collection would export the local Collection instead.

If exporting from a linked Collection should not be supported, bpy.data.collections[(collection, None)] can be used to only get a Collection local to the current file.

Otherwise, to get specific Collections, which could have the same name, linked from different libraries would require bpy.data.collections[(collection, library_filepath)] where library_filepath is the value of my_collection.library.filepath or None (when my_collection.library is None due to the Collection being local to the current file).

I don't know enough about how library linked data-blocks are used and supported by different parts of Blender to say if any changes are needed here.

Might want to consider whether performing a Collection export from a Collection linked from another file should be supported because a linked Collection can have the same name as a Collection local to the current file (or presumably another Collection linked from another different file). Currently, exporting from a linked Collection appears to work, but doesn't seem too useful because the Collection's children, export settings and export file path cannot be changed due to being linked from another file. I don't know if there is a guarantee that `bpy.data.collections[collection]` will always return a Collection from the current file in preference to a linked Collection with the same name, but it seems like that might be the case from a quick test using the Python Console. So, exporting from a linked Collection with the same name as a local Collection would export the local Collection instead. If exporting from a linked Collection should not be supported, `bpy.data.collections[(collection, None)]` can be used to only get a Collection local to the current file. Otherwise, to get specific Collections, which could have the same name, linked from different libraries would require `bpy.data.collections[(collection, library_filepath)]` where `library_filepath` is the value of `my_collection.library.filepath` or `None` (when `my_collection.library is None` due to the Collection being local to the current file). I don't know enough about how library linked data-blocks are used and supported by different parts of Blender to say if any changes are needed here.

Currently, exporting from a linked Collection appears to work, but doesn't seem too useful because the Collection's children, export settings and export file path cannot be changed due to being linked from another file.

Hmm, how did you arrive in this state? If you link in a Collection from foo.blend which has an exporter set you shouldn't see anything in the UI as it's not intended to be exportable in the current file. Are you seeing otherwise?

I don't know if there is a guarantee that bpy.data.collections[collection] will always return a Collection from the current file in preference to a linked Collection with the same name, but it seems like that might be the case from a quick test using the Python Console. So, exporting from a linked Collection with the same name as a local Collection would export the local Collection instead.
If exporting from a linked Collection should not be supported, bpy.data.collections[(collection, None)] can be used to only get a Collection local to the current file.

I'll make the change to use the None argument to make it more explicit.

> Currently, exporting from a linked Collection appears to work, but doesn't seem too useful because the Collection's children, export settings and export file path cannot be changed due to being linked from another file. Hmm, how did you arrive in this state? If you link in a Collection from foo.blend which has an exporter set you shouldn't see anything in the UI as it's not intended to be exportable in the current file. Are you seeing otherwise? > I don't know if there is a guarantee that `bpy.data.collections[collection]` will always return a Collection from the current file in preference to a linked Collection with the same name, but it seems like that might be the case from a quick test using the Python Console. So, exporting from a linked Collection with the same name as a local Collection would export the local Collection instead. > If exporting from a linked Collection should not be supported, `bpy.data.collections[(collection, None)]` can be used to only get a Collection local to the current file. I'll make the change to use the `None` argument to make it more explicit.
else: else:
operator.report({'ERROR'}, "Collection %s was not found" % collection) operator.report({'ERROR'}, "Collection '%s' was not found" % collection)
return {'CANCELLED'} return {'CANCELLED'}
if source_collection: if source_collection: