KhronosGroup / glTF-Blender-IO

Blender glTF 2.0 importer and exporter
https://docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html
Apache License 2.0
1.49k stars 316 forks source link

Allow appending new properties to the extras black list #1796

Open keianhzo opened 1 year ago

keianhzo commented 1 year ago

Is your feature request related to a problem? Please describe. When enabling "Export custom properties as glTF extras" in the exporter settings certain properties that are not serializable will throw an exception. There is currently a BLACK_LIST in the gltf2_blender_extras module that is used to exclude certain properties from serialization. https://github.com/KhronosGroup/glTF-Blender-IO/blob/9be538a53c374b50e109022965886f49d1eb4806/addons/io_scene_gltf2/blender/com/gltf2_blender_extras.py#L21 But this list is not exposed through the API for external consume.

Describe the solution you'd like I think it would be useful to expose an API method to append properties that are known to break to that blacklist so add-ons that are adding non serializable properties can easily exclude them from export.

I'll open a PR proposal as soon as a I can.

Describe alternatives you've considered We are currently just importing the BLACK_LIST list and manually appending the new names before exporting.

class glTF2ExportUserExtension:
    def __init__(self):
        from io_scene_gltf2.blender.com.gltf2_blender_extras import BLACK_LIST
        for _, component_class in get_components_registry().items():
            BLACK_LIST.append(component_class.get_id())

but this is doomed to break as soon as that changes on the glTF add-on side.

fy0 commented 1 year ago

It's better to have a filter function, users can manually change the extra data.

Ali-RS commented 1 year ago

I second this feature.

Please see this issue: https://github.com/Takanu/Capsule/issues/46

It will be nice to have some API (both via code and gltf export panel UI) to filter out unwanted "custom properties" that might be added by other add-ons for their internal use.

barrykeenanresn commented 1 year ago

This would be a great feature.

Is there currently anyway to exclude properties from being exported apart from modifying the BLACK_LIST mentioned above?

I'm making an add-on that has a Panel and custom PropertyGroup. The PropertyGroup has an Object property. When the export runs I get TypeError: cannot pickle 'Object' object, Coming from gltf2_blender_gather_materials.py, line 99, in gather_material, material = deepcopy(base_material)

I can't figure out how to exclude or hide that particular property in my add-on at the Panel or PropertyGroup layer. I've also thought about adding a to_dict() method or similar, so the Object gets serialised with just an id or name. But haven't been able to figure it out.

So the only other alternative I can think of is to exclude the custom PropertyGroup from being exported. +1 for this feature please :)

julienduroure commented 1 year ago

About this => See draft PR #1917