Name of custom socket types is not set when making a node group via script. #91658

Open
opened 2021-09-23 21:31:55 +02:00 by Jeroen Bakker · 4 comments
Member

System Information
Operating system: Linux-5.11.0-36-generic-x86_64-with-glibc2.33 64 Bits
Graphics card: Mesa Intel(R) UHD Graphics 620 (KBL GT2) Intel 4.6 (Core Profile) Mesa 21.0.3

Blender Version
Broken: version: 3.0.0 Alpha, branch: master, commit date: 2021-09-23 17:39, hash: b8a30c7664
Worked: (newest version of Blender that worked as expected)

Short description of error
When making a node group via a script, the custom socket type name is not set.

Exact steps for others to reproduce the error

import bpy
import nodeitems_utils

class CSTree(bpy.types.NodeTree):
    bl_idname = 'CSTree'
    bl_label = "CS Node Editor"
    bl_icon = 'NODETREE'
    

class CSSocket(bpy.types.NodeSocket):
    bl_idname = 'CSSocket'
    bl_label = "CS Socket"

    def draw(self, context, layout, node, text):
        layout.label(text=text)

    def draw_color(self, context, node):
        return (1.0, 0.8, 0.4, 1.0)


class CSSocketInterface(bpy.types.NodeSocketInterface):
    bl_idname = "CSSocketInterface"
    bl_socket_idname = "CSSocket"
    bl_label = "CS Socket"

    def draw_color(self, context):
        return (1.0, 0.8, 0.4, 1.0)

    def draw(self, context, layout):
        pass


class CSNode(bpy.types.Node):
    bl_idname = 'CSNode'
    bl_label = "Node"

    def init(self, context):
        self.inputs.new('CSSocket', name='Input1')


class CSNodeGroup(bpy.types.NodeCustomGroup):
    bl_idname = 'CSNodeGroup'
    bl_label = 'Node Group'
    bl_icon = 'OUTLINER_OB_EMPTY'

    def init(self, context):
        self.node_tree = bpy.data.node_groups.new('CSNodeGroup', 'CSTree')
        nodes = self.node_tree.nodes
        inputnode = nodes.new('NodeGroupInput')


def make_group(context):
    space_data = context.space_data
    node_tree = space_data.node_tree
    selected_nodes = context.selected_nodes
    node_group = node_tree.nodes.new("CSNodeGroup")
    node_group_tree = node_group.node_tree
    input_group = node_group_tree.nodes['Group Input']
    
    new_node = node_group_tree.nodes.new("CSNode")

    to_socket = new_node.inputs[0]
    from_socket = input_group.outputs.new(to_socket.bl_idname, to_socket.name)
    node_group_tree.links.new(input=from_socket, output=to_socket)
    

class CSMakeNodeGroupOperator(bpy.types.Operator):
    bl_idname = "crowd.cs_make_group"
    bl_label = "CS Make Group"
    
    @classmethod
    def poll(cls, context):
        space_data = context.space_data

        if not (space_data.type == 'NODE_EDITOR'
            and space_data.tree_type == 'CSTree'
            and space_data.node_tree is not None):
            return False

        return True
    
    def execute(self, context):
        node_group = make_group(context)
        return {'FINISHED'}


def register():
    bpy.utils.register_class(CSTree)
    bpy.utils.register_class(CSSocket)
    bpy.utils.register_class(CSNode)
    bpy.utils.register_class(CSNodeGroup)
    bpy.utils.register_class(CSMakeNodeGroupOperator)

def unregister():
    bpy.utils.unregister_class(CSTree)
    bpy.utils.unregister_class(CSSocket)
    bpy.utils.unregister_class(CSNode)
    bpy.utils.unregister_class(CSNodeGroup)
    bpy.utils.unregister_class(CSMakeNodeGroupOperator)

if __name__ =="__main__":
    register()

  • execute script
  • open CS Node Editor
  • create new node tree
  • Search for "CS Make Group" operator
  • switch to "CSNodeGroup" tree
  • Open side panel (N)
  • Check that the Group/Inputs has one item, but the name in the list is blank.

{F10562486 width=100%}

**System Information** Operating system: Linux-5.11.0-36-generic-x86_64-with-glibc2.33 64 Bits Graphics card: Mesa Intel(R) UHD Graphics 620 (KBL GT2) Intel 4.6 (Core Profile) Mesa 21.0.3 **Blender Version** Broken: version: 3.0.0 Alpha, branch: master, commit date: 2021-09-23 17:39, hash: `b8a30c7664` Worked: (newest version of Blender that worked as expected) **Short description of error** When making a node group via a script, the custom socket type name is not set. **Exact steps for others to reproduce the error** * load script [P2427: Example of socket interface](https://archive.blender.org/developer/P2427.txt) ```python import bpy import nodeitems_utils class CSTree(bpy.types.NodeTree): bl_idname = 'CSTree' bl_label = "CS Node Editor" bl_icon = 'NODETREE' class CSSocket(bpy.types.NodeSocket): bl_idname = 'CSSocket' bl_label = "CS Socket" def draw(self, context, layout, node, text): layout.label(text=text) def draw_color(self, context, node): return (1.0, 0.8, 0.4, 1.0) class CSSocketInterface(bpy.types.NodeSocketInterface): bl_idname = "CSSocketInterface" bl_socket_idname = "CSSocket" bl_label = "CS Socket" def draw_color(self, context): return (1.0, 0.8, 0.4, 1.0) def draw(self, context, layout): pass class CSNode(bpy.types.Node): bl_idname = 'CSNode' bl_label = "Node" def init(self, context): self.inputs.new('CSSocket', name='Input1') class CSNodeGroup(bpy.types.NodeCustomGroup): bl_idname = 'CSNodeGroup' bl_label = 'Node Group' bl_icon = 'OUTLINER_OB_EMPTY' def init(self, context): self.node_tree = bpy.data.node_groups.new('CSNodeGroup', 'CSTree') nodes = self.node_tree.nodes inputnode = nodes.new('NodeGroupInput') def make_group(context): space_data = context.space_data node_tree = space_data.node_tree selected_nodes = context.selected_nodes node_group = node_tree.nodes.new("CSNodeGroup") node_group_tree = node_group.node_tree input_group = node_group_tree.nodes['Group Input'] new_node = node_group_tree.nodes.new("CSNode") to_socket = new_node.inputs[0] from_socket = input_group.outputs.new(to_socket.bl_idname, to_socket.name) node_group_tree.links.new(input=from_socket, output=to_socket) class CSMakeNodeGroupOperator(bpy.types.Operator): bl_idname = "crowd.cs_make_group" bl_label = "CS Make Group" @classmethod def poll(cls, context): space_data = context.space_data if not (space_data.type == 'NODE_EDITOR' and space_data.tree_type == 'CSTree' and space_data.node_tree is not None): return False return True def execute(self, context): node_group = make_group(context) return {'FINISHED'} def register(): bpy.utils.register_class(CSTree) bpy.utils.register_class(CSSocket) bpy.utils.register_class(CSNode) bpy.utils.register_class(CSNodeGroup) bpy.utils.register_class(CSMakeNodeGroupOperator) def unregister(): bpy.utils.unregister_class(CSTree) bpy.utils.unregister_class(CSSocket) bpy.utils.unregister_class(CSNode) bpy.utils.unregister_class(CSNodeGroup) bpy.utils.unregister_class(CSMakeNodeGroupOperator) if __name__ =="__main__": register() ``` * execute script * open CS Node Editor * create new node tree * Search for "CS Make Group" operator * switch to "CSNodeGroup" tree * Open side panel (N) * Check that the Group/Inputs has one item, but the name in the list is blank. {[F10562486](https://archive.blender.org/developer/F10562486/image.png) width=100%}
Author
Member

Added subscriber: @Jeroen-Bakker

Added subscriber: @Jeroen-Bakker

Added subscriber: @iss

Added subscriber: @iss

This is crashing for me in one of steps:

  • Search (and run) for "CS Make Group" operator
  • Switch to "CSNodeGroup" tree
This is crashing for me in one of steps: - Search (and run) for "CS Make Group" operator - Switch to "CSNodeGroup" tree

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Philipp Oeser removed the
Interest
Python API
label 2023-02-10 09:04:30 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#91658
No description provided.