Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function - To delete all glTf Settings.xxx and reassign to Proper glTf Settings #290

Open
ronh991 opened this issue Nov 20, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@ronh991
Copy link
Contributor

ronh991 commented Nov 20, 2023

When a developer merges/appends objects from other blend files and those objects have the same material. The glTf Setting node gets incremented by adding a .00x to it. These produce warning errors on export about Occlusion/Comp materials.

DA40_CGDFQ_2023 11 19_13h48m50s

DA40_CGDFQ_2023 11 19_13h49m7s

PR? add to msfs_material_panel.py


class MSFS_OT_glTfSettingsMaterialData(bpy.types.Operator): # TODO: Remove eventually
    """This addon changes some of the internal property names. glTf Settings will be updated for ALL materials."""

    bl_idname = "msfs.gltfsetttings_material_data"
    bl_label = "Reset glTf Settings Material Data"


    @staticmethod
    def gltf_settings_with_dot_present():
        # Ensure the material has a shader node tree
        for material in bpy.data.materials:
            if material.use_nodes:
                for node in material.node_tree.nodes:
                    # Check if the node is a group node with a name "glTF Settings new"
                    if node.type == 'GROUP' and node.node_tree and ( 'glTF Settings.' in node.node_tree.name)  :
                        return True
        return False

    def execute(self, context):
        # Ensure the material has a shader node tree
        for material in bpy.data.materials:
            if material.use_nodes:
                for node in material.node_tree.nodes:
                    # Check if the node is a group node with a name "glTF Settings new"
                    if node.type == 'GROUP' and node.node_tree and ( 'glTF Settings.' in node.node_tree.name)  :
                        # Reassign the proper node group
                        proper_occlusion_node_tree = bpy.data.node_groups.get("glTF Settings")
                        node.node_tree = proper_occlusion_node_tree
                        print(f"Reassigned 'glTF Settings.xxx' to 'glTF Settings' in material  '{material.name}'",  node.node_tree.name)
        return {"FINISHED"}

then add

        if mat:
            if MSFS_OT_glTfSettingsMaterialData.gltf_settings_with_dot_present():
                layout.operator(MSFS_OT_glTfSettingsMaterialData.bl_idname)

@y-khodja y-khodja added the enhancement New feature or request label Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants