Fix: Python node_utils.connect_sockets broken after API change #113630
No reviewers
Labels
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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#113630
Loading…
Reference in New Issue
No description provided.
Delete Branch "pioverfour/blender:dp_node_utils_fix_connect"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
After the recent introduction of node panels, the utility that
allowed scripters to connect sockets to or from a virtual socket was
broken. This happens when creating an interface before connecting
sockets. Sockets can have a subtype, while interfaces cannot.
For instance, the
NodeSocketFloatFactor
type cannot be useddirectly, it has to be converted to
NodeSocketFloat
.This commit chooses an appropriate type for the new interface before
creating it, based on the socket's
type
property.I think what I’m doing is stupid: using a regex to manipulate the name of the socket type, instead of programmatically finding its base type. However I couldn’t find a way to do that,bl_rna.base
is useless here and so is themro
.@LukasTonne I think you implemented the interface panels? Is there a more reliable way to find a socket’s base type?
Attached is an example use case for this PR. The script uses
bpy_extras.node_utils.connect_sockets
to create group inputs from the Principled BSDF node.Also, this fixes Node Wrangler’s lazy connect.
I'd like to have a more robust way to find a valid base type from subclass on the C++ side. The
new_socket
method could do this internally, i think it's the only method in group interface API that takes a socket type name directly. Could also have a utility function but i don't think it's really necessary outside of this case. I'll take a look.Ok, some complication: The interface sockets have to use the restricted list of socket base types for their enum items, otherwise we'd have to do internal checks and custom validation, which gets messy and confusing. A utility function to return a valid type like the one in this patch would be a cleaner solution, but then implemented based on actual type inheritance.
I can't find a good way to do this in RNA, there are just too many limitations. I propose to do this the simple way, otherwise the function will not handle custom socket types correctly which do not necessarily follow the CamelCase pattern of the built-in socket types. I've tried making this smarter based on python class inheritance or concatenating the enum name with
NodeSocket
+name, but there are too many inconsistencies to make this work (e.g. "RGBA" vs "Color").Writing an automated test for this would be nice, but i don't have time right now.
@LukasTonne Thanks for looking into it. I applied your diff, simply removed the unused
import bpy
.Should this go to 4.0 instead of main?
Python API: fix node_utils.connect_sockets after API changeto Python API: fix node_utils.connect_sockets after API change21dbdd8cb1
to8c58f03b60
Yes, I rebased just now. Thanks
Python API: fix node_utils.connect_sockets after API changeto Fix: Python node_utils.connect_sockets broken after API change