Skip to content

New placement for the Import/Export buttons for node groups #142

@kolibril13

Description

@kolibril13

Placement idea for the import export buttons:
Image

Prompt engineered:

import bpy


# ------------------------------------------------------------
# Operators
# ------------------------------------------------------------

class GN_OT_import_nodes(bpy.types.Operator):
    bl_idname = "gn.import_nodes"
    bl_label = "Import Geometry Nodes"
    bl_description = "Import a Geometry Nodes setup"

    def execute(self, context):
        self.report({'INFO'}, "Import clicked")
        return {'FINISHED'}


class GN_OT_export_nodes(bpy.types.Operator):
    bl_idname = "gn.export_nodes"
    bl_label = "Export Geometry Nodes"
    bl_description = "Export the active Geometry Nodes setup"

    def execute(self, context):
        self.report({'INFO'}, "Export clicked")
        return {'FINISHED'}


# ------------------------------------------------------------
# Header draw 
# ------------------------------------------------------------

def draw_gn_header_right(self, context):
    space = context.space_data

    if not space:
        return
    if space.type != 'NODE_EDITOR':
        return
    if space.tree_type != 'GeometryNodeTree':
        return
    if not space.node_tree:
        return

    layout = self.layout
    layout.separator()

    row = layout.row(align=True)
    row.operator(
        GN_OT_import_nodes.bl_idname,
        text="Import",
        icon='IMPORT'
    )
    row.operator(
        GN_OT_export_nodes.bl_idname,
        text="Export",
        icon='EXPORT'
    )


# ------------------------------------------------------------
# Registration
# ------------------------------------------------------------

classes = (
    GN_OT_import_nodes,
    GN_OT_export_nodes,
)


def register():
    for cls in classes:
        bpy.utils.register_class(cls)

    bpy.types.NODE_HT_header.append(draw_gn_header_right)


def unregister():
    bpy.types.NODE_HT_header.remove(draw_gn_header_right)

    for cls in reversed(classes):
        bpy.utils.unregister_class(cls)


if __name__ == "__main__":
    register()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions