Takanu / Capsule

(Blender 4.1) Universal batch export manager
https://takanu.itch.io/capsule-blender-addon
GNU General Public License v3.0
200 stars 13 forks source link

Prevent Capsule added "custom properties" from exporting into gltf extras #46

Open Ali-RS opened 1 year ago

Ali-RS commented 1 year ago

Hi

When I export an object with Capsule addon to a Gltf file with "custom properties" I see there are other unrelated properties are also exported that seem to be added by this addon.

Here is an example gltf:

(Notice the CAPScn, CAPStatus, CAPProxy, and CAPObj)

    "scenes" : [
        {
            "extras" : {
                "CAPScn" : {
                    "object_list" : [
                        {
                            "object" : {
                                "name" : "Cube",
                                "type" : "Object"
                            },
                            "enable_export" : 1
                        }
                    ],
                    "selection_switch" : 0
                },
                "CAPProxy" : {
                    "disable_updates" : 0,
                    "obj_enable_export" : 1,
                    "obj_origin_point" : 0,
                    "obj_location_preset" : 1,
                    "obj_export_preset" : 2,
                    "obj_pack_script" : null,
                    "col_enable_export" : 0,
                    "col_origin_point" : 0,
                    "col_root_object" : null,
                    "col_child_export_option" : 0,
                    "col_location_preset" : 0,
                    "col_export_preset" : 0,
                    "col_pack_script" : null
                },
                "CAPStatus" : {
                    "target_name" : "",
                    "target_status" : 0,
                    "target_input" : [],
                    "target_output" : []
                }
            },
            "name" : "Scene",
            "nodes" : [
                0
            ]
        }
    ],
"nodes" : [
        {
            "extras" : {
                "prop" : "test",
                "CAPObj" : {
                    "pack_script" : {},
                    "enable_edit" : 1,
                    "enable_export" : 1,
                    "in_export_list" : 1,
                    "export_preset" : 2,
                    "location_preset" : 1
                }
            },
            "mesh" : 0,
            "name" : "Cube"
        }
    ],

How can I prevent Capsule properties (CAPScn, CAPStatus, CAPProxy, CAPObj,...) from exporting?

Regards

Takanu commented 1 year ago

Thanks for the report. This might be possible in the future but it'd require making and deleting duplicates of export targets which has it's own share of potential problems. The data you're seeing is required for Capsule to function - it can't be moved anywhere else.

Ali-RS commented 1 year ago

I see, thanks.

For now, I am going to use the trick provided in https://github.com/KhronosGroup/glTF-Blender-IO/issues/1796 by filtering out those properties from exporting into gltf.

import bpy

EXCLUDED_PROPERTIES = ['CAPScn', 'CAPStatus', 'CAPProxy', 'CAPObj']

from io_scene_gltf2.blender.com.gltf2_blender_extras import BLACK_LIST
for excluded_prop in EXCLUDED_PROPERTIES:
    BLACK_LIST.append(excluded_prop)