Node Wrangler: Switch Type shows empty menu #101514

Open
opened 2022-10-01 10:04:39 +02:00 by Sun Kim · 26 comments
Contributor

System Information
Operating system: Windows-10-10.0.19043-SP0 64 Bits
Graphics card: Radeon RX 570 Series ATI Technologies Inc. 4.5.14800 Core Profile Context 22.5.1 30.0.15021.11005

Blender Version
Broken: version: 3.4.0 Alpha, branch: master, commit date: 2022-09-30 22:40, hash: blender/blender@206dead860
Worked: version: 3.4.0 Alpha, branch: master, commit date: 2022-09-26 00:52, hash: blender/blender@3a7dc572dc

Probably caused by 837144b4577f. This is the only relevant commit from Blender side between working and broken versions.

Short description of error
Node Wrangler's Switch Type shows empty menu in Geometry Nodes. It works in Shader and Compositor node.

{F13601512, size=full}

Exact steps for others to reproduce the error

  • Add Geometry Nodes to object
  • Select any node, try Switch Type (Shift + S). Only shows empty menu
  • The same with Switch Type button from sidebar
**System Information** Operating system: Windows-10-10.0.19043-SP0 64 Bits Graphics card: Radeon RX 570 Series ATI Technologies Inc. 4.5.14800 Core Profile Context 22.5.1 30.0.15021.11005 **Blender Version** Broken: version: 3.4.0 Alpha, branch: master, commit date: 2022-09-30 22:40, hash: `blender/blender@206dead860` Worked: version: 3.4.0 Alpha, branch: master, commit date: 2022-09-26 00:52, hash: `blender/blender@3a7dc572dc` Probably caused by `837144b4577f`. This is the only relevant commit from Blender side between working and broken versions. **Short description of error** Node Wrangler's Switch Type shows empty menu in Geometry Nodes. It works in Shader and Compositor node. {[F13601512](https://archive.blender.org/developer/F13601512/EmptySwitchMenu.png), size=full} **Exact steps for others to reproduce the error** * Add Geometry Nodes to object * Select any node, try Switch Type (`Shift + S`). Only shows empty menu * The same with Switch Type button from sidebar
Author
Contributor

Added subscriber: @persun

Added subscriber: @persun

#103607 was marked as duplicate of this issue

#103607 was marked as duplicate of this issue

#102291 was marked as duplicate of this issue

#102291 was marked as duplicate of this issue

Added subscriber: @user1

Added subscriber: @user1

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

Changed status from 'Needs Triage' to: 'Archived'
user1 closed this issue 2022-10-01 14:06:46 +02:00

Not sure, but you should be able to change the tag to something like "addons", since nodewrangler is an addon, right? Apart from that, i confirm that the wrangler is broken.

Not sure, but you should be able to change the tag to something like "addons", since nodewrangler is an addon, right? Apart from that, i confirm that the wrangler is broken.
Author
Contributor

In #101514#1426111, @user1 wrote:
you should be able to change the tag to something like "addons"

Sure. I think this is caused by a change from Blender side, so I'll leave BF Blender too.

But why did you archived this?

> In #101514#1426111, @user1 wrote: > you should be able to change the tag to something like "addons" Sure. I think this is caused by a change from Blender side, so I'll leave BF Blender too. But why did you archived this?

Changed status from 'Archived' to: 'Confirmed'

Changed status from 'Archived' to: 'Confirmed'

Added subscriber: @mano-wii

Added subscriber: @mano-wii
Member

Added subscriber: @heini

Added subscriber: @heini
Member

Added subscribers: @HooglyBoogly, @wannes.malfait

Added subscribers: @HooglyBoogly, @wannes.malfait
Member

This is a regression and should be fixed before 3.4 gets released.
Caused by blender/blender@837144b457 (as far as I can tell).
@HooglyBoogly Any idea on how to fix this?

This is a regression and should be fixed before 3.4 gets released. Caused by blender/blender@837144b457 (as far as I can tell). @HooglyBoogly Any idea on how to fix this?
Member

This hack makes the add menu behave like the switch node type menu, but I don't see a way to make this work from inside node wrangler without basically duplicating all the code in node_add_menu_geometry.py and node_add_menu.py.

diff --git a/release/scripts/startup/bl_ui/node_add_menu.py b/release/scripts/startup/bl_ui/node_add_menu.py
index 873dbd533a5..4e76bfedd60 100644
--- a/release/scripts/startup/bl_ui/node_add_menu.py
+++ b/release/scripts/startup/bl_ui/node_add_menu.py
@@ -13,9 +13,9 @@ def add_node_type(layout, node_type, *, label=None):
     if not label:
         label = bl_rna.name if bl_rna else iface_("Unknown")
     translation_context = bl_rna.translation_context if bl_rna else i18n_contexts.default
-    props = layout.operator("node.add_node", text=label, text_ctxt=translation_context)
-    props.type = node_type
-    props.use_transform = True
+    props = layout.operator("node.nw_switch_node_type", text=label, text_ctxt=translation_context)
+    props.to_type = node_type
+    props.node_group = ''
     return props
 
 
@@ -54,9 +54,7 @@ def draw_node_group_add_menu(context, layout):
             layout.separator()
             for group in groups:
                 props = add_node_type(layout, node_tree_group_type[group.bl_idname], label=group.name)
-                ops = props.settings.add()
-                ops.name = "node_tree"
-                ops.value = "bpy.data.node_groups[%r]" % group.name
+                props.node_group = group.name
 
 
 def draw_assets_for_catalog(layout, catalog_path):
diff --git a/node_wrangler.py b/node_wrangler.py
index 5932388f..03a911f5 100644
--- a/node_wrangler.py
+++ b/node_wrangler.py
@@ -1707,7 +1707,7 @@ class NWReloadImages(Operator):
 
 class NWSwitchNodeType(Operator, NWBase):
     """Switch type of selected nodes """
-    bl_idname = "node.nw_swtch_node_type"
+    bl_idname = "node.nw_switch_node_type"
     bl_label = "Switch Node Type"
     bl_options = {'REGISTER', 'UNDO'}
 
@@ -1716,6 +1716,11 @@ class NWSwitchNodeType(Operator, NWBase):
         default = '',
     )
 
+    node_group: StringProperty(
+        name="Node group name",
+        default = '',
+    )
+
     def execute(self, context):
         to_type = self.to_type
         if len(to_type) == 0:
@@ -1735,6 +1740,10 @@ class NWSwitchNodeType(Operator, NWBase):
                      n.rna_type.identifier not in src_excludes and
                      n.rna_type.identifier != to_type]:
             new_node = nodes.new(to_type)
+
+            if self.node_group != '':
+                new_node.node_tree = bpy.data.node_groups[self.node_group]
+                    
             for attr in attrs_to_pass:
                 if hasattr(node, attr) and hasattr(new_node, attr):
                     setattr(new_node, attr, getattr(node, attr))

This hack makes the add menu behave like the switch node type menu, but I don't see a way to make this work from inside node wrangler without basically duplicating all the code in `node_add_menu_geometry.py` and `node_add_menu.py`. ``` diff --git a/release/scripts/startup/bl_ui/node_add_menu.py b/release/scripts/startup/bl_ui/node_add_menu.py index 873dbd533a5..4e76bfedd60 100644 --- a/release/scripts/startup/bl_ui/node_add_menu.py +++ b/release/scripts/startup/bl_ui/node_add_menu.py @@ -13,9 +13,9 @@ def add_node_type(layout, node_type, *, label=None): if not label: label = bl_rna.name if bl_rna else iface_("Unknown") translation_context = bl_rna.translation_context if bl_rna else i18n_contexts.default - props = layout.operator("node.add_node", text=label, text_ctxt=translation_context) - props.type = node_type - props.use_transform = True + props = layout.operator("node.nw_switch_node_type", text=label, text_ctxt=translation_context) + props.to_type = node_type + props.node_group = '' return props @@ -54,9 +54,7 @@ def draw_node_group_add_menu(context, layout): layout.separator() for group in groups: props = add_node_type(layout, node_tree_group_type[group.bl_idname], label=group.name) - ops = props.settings.add() - ops.name = "node_tree" - ops.value = "bpy.data.node_groups[%r]" % group.name + props.node_group = group.name def draw_assets_for_catalog(layout, catalog_path): ``` ``` diff --git a/node_wrangler.py b/node_wrangler.py index 5932388f..03a911f5 100644 --- a/node_wrangler.py +++ b/node_wrangler.py @@ -1707,7 +1707,7 @@ class NWReloadImages(Operator): class NWSwitchNodeType(Operator, NWBase): """Switch type of selected nodes """ - bl_idname = "node.nw_swtch_node_type" + bl_idname = "node.nw_switch_node_type" bl_label = "Switch Node Type" bl_options = {'REGISTER', 'UNDO'} @@ -1716,6 +1716,11 @@ class NWSwitchNodeType(Operator, NWBase): default = '', ) + node_group: StringProperty( + name="Node group name", + default = '', + ) + def execute(self, context): to_type = self.to_type if len(to_type) == 0: @@ -1735,6 +1740,10 @@ class NWSwitchNodeType(Operator, NWBase): n.rna_type.identifier not in src_excludes and n.rna_type.identifier != to_type]: new_node = nodes.new(to_type) + + if self.node_group != '': + new_node.node_tree = bpy.data.node_groups[self.node_group] + for attr in attrs_to_pass: if hasattr(node, attr) and hasattr(new_node, attr): setattr(new_node, attr, getattr(node, attr)) ```

Added subscriber: @ThomasDinges

Added subscriber: @ThomasDinges

@HooglyBoogly Can you please take a look?

@HooglyBoogly Can you please take a look?
Member

Sorry for the delayed response here.
I'm not sure if I'm going to have time to look into this today. I'm also not that experienced with the Python API so I'm not exactly sure how to do this at the moment, but the approach I'd try is scanning over the nodes in bpy.types. From there I assume we could check if the type is compatible with the current tree. If the operator needs to know the default sockets of the node, I assume we would have to add a dummy node to check.

Sorry for the delayed response here. I'm not sure if I'm going to have time to look into this today. I'm also not that experienced with the Python API so I'm not exactly sure how to do this at the moment, but the approach I'd try is scanning over the nodes in `bpy.types`. From there I assume we could check if the type is compatible with the current tree. If the operator needs to know the default sockets of the node, I assume we would have to add a dummy node to check.
Member

In #101514#1455405, @HooglyBoogly wrote:
Sorry for the delayed response here.
I'm not sure if I'm going to have time to look into this today. I'm also not that experienced with the Python API so I'm not exactly sure how to do this at the moment, but the approach I'd try is scanning over the nodes in bpy.types. From there I assume we could check if the type is compatible with the current tree. If the operator needs to know the default sockets of the node, I assume we would have to add a dummy node to check.

Problem is that you can't build the menu from bpy.types information. You don't have information on the way the nodes are organized into submenus. The operator works in two steps:

  • A menu is shown (essentially identical to the add menu) from which the user can select a node type. This is no longer possible with the current python API without copy pasting 90% of the code in node_add_menu_geometry.py
  • This node type is then used to call the nw_switch_node_type operator which does the actual "work". This operator is not really affected by this regression.

If there was some way to pass your own "on_click" operator to the "add menu" via the python API, then the problem would be gone.

> In #101514#1455405, @HooglyBoogly wrote: > Sorry for the delayed response here. > I'm not sure if I'm going to have time to look into this today. I'm also not that experienced with the Python API so I'm not exactly sure how to do this at the moment, but the approach I'd try is scanning over the nodes in `bpy.types`. From there I assume we could check if the type is compatible with the current tree. If the operator needs to know the default sockets of the node, I assume we would have to add a dummy node to check. Problem is that you can't build the menu from `bpy.types` information. You don't have information on the way the nodes are organized into submenus. The operator works in two steps: - A menu is shown (essentially identical to the add menu) from which the user can select a node type. This is no longer possible with the current python API without copy pasting 90% of the code in `node_add_menu_geometry.py` - This node type is then used to call the `nw_switch_node_type` operator which does the actual "work". This operator is not really affected by this regression. If there was some way to pass your own "on_click" operator to the "add menu" via the python API, then the problem would be gone.

Added subscriber: @Raimund58

Added subscriber: @Raimund58

Added subscriber: @Dillen

Added subscriber: @Dillen

I'm also having the same problem. Including all the information that I have.
System Information
Operating system: Linux-5.4.0-135-generic-x86_64-with-glibc2.31 64 Bits
Graphics card: NVIDIA GeForce GT 1030/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 470.161.03

Blender Version
Broken: version: 3.4.0, branch: blender-v3.4-release, commit date: 2022-12-06 18:46, hash: blender/blender@a95bf1ac01

            version: 3.4.1 Release Candidate, branch: blender-v3.4-release, commit date: 2022-12-16 14:49, hash: `rBb87bcd3f8fe1`
            version: 3.5.0 Alpha, branch: master, commit date: 2022-12-17 13:46, hash: `rB28511ac6cf83`

Worked: version: 3.3.2, branch: master, commit date: 2022-12-07 12:12, hash: blender/blender@bd3a7b41e2

Addon Information
Name: Node Wrangler (3.41[Blender 3.4.0]) (3.43[Blender 3.5 & 3.4.1])
Author: Bartek Skorupa, Greg Zaal, Sebastian Koenig, Christian Brinkmann, Florian Meyer

Short description of error
Node Wrangler Switch type to(shift+S or Shift+W or through sidebar) in Geometry nodes editor doesn't enum the list of nodes and Alt+Shift+D always crashes blender.

Exact steps for others to reproduce the error

  1. Change timeline editor to Geometry node editor. Add a primitive of any kind(Shift+a). Select it and try to change the node type(Shift+S or Shift+w->Switch Node Type). Nothing shows in the list.
  2. To crash blender select a node connected or not in either shader editor or geometry node editor and with mouse cursor over the editor press Alt+Shift+D.
I'm also having the same problem. Including all the information that I have. **System Information** Operating system: Linux-5.4.0-135-generic-x86_64-with-glibc2.31 64 Bits Graphics card: NVIDIA GeForce GT 1030/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 470.161.03 **Blender Version** Broken: version: 3.4.0, branch: blender-v3.4-release, commit date: 2022-12-06 18:46, hash: `blender/blender@a95bf1ac01` ``` version: 3.4.1 Release Candidate, branch: blender-v3.4-release, commit date: 2022-12-16 14:49, hash: `rBb87bcd3f8fe1` version: 3.5.0 Alpha, branch: master, commit date: 2022-12-17 13:46, hash: `rB28511ac6cf83` ``` Worked: version: 3.3.2, branch: master, commit date: 2022-12-07 12:12, hash: `blender/blender@bd3a7b41e2` **Addon Information** Name: Node Wrangler (3.41[Blender 3.4.0]) (3.43[Blender 3.5 & 3.4.1]) Author: Bartek Skorupa, Greg Zaal, Sebastian Koenig, Christian Brinkmann, Florian Meyer **Short description of error** Node Wrangler Switch type to(shift+S or Shift+W or through sidebar) in Geometry nodes editor doesn't enum the list of nodes and Alt+Shift+D always crashes blender. **Exact steps for others to reproduce the error** 1. Change timeline editor to Geometry node editor. Add a primitive of any kind(Shift+a). Select it and try to change the node type(Shift+S or Shift+w->Switch Node Type). Nothing shows in the list. 2. To crash blender select a node connected or not in either shader editor or geometry node editor and with mouse cursor over the editor press Alt+Shift+D.

Added subscriber: @KiralyMarta

Added subscriber: @KiralyMarta

@HooglyBoogly Any updates here?

@HooglyBoogly Any updates here?
Member

Unfortunately I just don't see a viable way to fix this right now besides duplicating the whole menu for node wrangler. This whole area has changed fundamentally recently, with the add menu being extended with asset node groups (a fundamental part of the design for the node editor and geometry nodes going forward) more levels of nesting in the menu, and a related refactor to how the add menu is created.
If we went with a hack, we could make this work for a bit, but we would be missing the asset integration here too, which will only get more important. I plan to change this area more in the near future, by looking into adding a callback to node types to tell where they are in the menu and using that to build the menu. This may make fixing this report easier, but I'm not sure.

Since I can't predict when this can be fixed, I'll make it a known issue.
Also, I wonder if making this a native Blender feature would be a better path in the end.

Unfortunately I just don't see a viable way to fix this right now besides duplicating the whole menu for node wrangler. This whole area has changed fundamentally recently, with the add menu being extended with asset node groups (a fundamental part of the design for the node editor and geometry nodes going forward) more levels of nesting in the menu, and a related refactor to how the add menu is created. If we went with a hack, we could make this work for a bit, but we would be missing the asset integration here too, which will only get more important. I plan to change this area more in the near future, by looking into adding a callback to node types to tell where they are in the menu and using that to build the menu. This *may* make fixing this report easier, but I'm not sure. Since I can't predict when this can be fixed, I'll make it a known issue. Also, I wonder if making this a native Blender feature would be a better path in the end.

Just out of curiosity, how was the menu for Switch Node Type generated in the Shading nodes? Was the Add menu replicated there? If it was something specific to Shading, perhaps a rethink might be in order. From what I understand, Blender is going to handle more and more things via Nodes. Perhaps an addition to the coding standard? Like maybe a categorized list of Nodes, per the Add menu, specific to the kind of Nodes being used (Shading, Geometry, whatever-the-next-one-is). This could be accessed both by Node Wrangler in Switch Node Type, and in the core code by the Add menu proper. Should changes or reorganizations in that list be made, being centralized, it would update in both the core and Node Wrangler.

(My apologies, @HooglyBoogly , it I am overstepping. Although I have some background in coding, it's 10 years out of date, and even if it were current I can never keep the buzzwords straight.)

Just out of curiosity, how was the menu for Switch Node Type generated in the Shading nodes? Was the Add menu replicated there? If it was something specific to Shading, perhaps a rethink might be in order. From what I understand, Blender is going to handle more and more things via Nodes. Perhaps an addition to the coding standard? Like maybe a categorized list of Nodes, per the Add menu, specific to the kind of Nodes being used (Shading, Geometry, whatever-the-next-one-is). This could be accessed both by Node Wrangler in Switch Node Type, and in the core code by the Add menu proper. Should changes or reorganizations in that list be made, being centralized, it would update in both the core and Node Wrangler. (My apologies, @HooglyBoogly , it I am overstepping. Although I have some background in coding, it's 10 years out of date, and even if it were current I can never keep the buzzwords straight.)
Author
Contributor

I think it's worth to note here that with the recent refactor of add menus in other node editors (75919610b4, 5fac8f822b, 9db4c0ca4b), Switch Type operator is no longer operational in any node editor.

At the same time, there's a design discussion to make this a native function to Blender, named "Swap Node" operator.

Since it's not functional anymore and the alternative will be a native one anyway, I think Switch Type function should be removed from Node Wrangler in 4.0.

I think it's worth to note here that with the recent refactor of add menus in other node editors (https://projects.blender.org/blender/blender/commit/75919610b40e6f6c6eea8246185fc565adbc950a, https://projects.blender.org/blender/blender/commit/5fac8f822b9357554a999f6370ecad81acd79314, https://projects.blender.org/blender/blender/commit/9db4c0ca4be17e71cb062e3c489a80780847ea31), Switch Type operator is no longer operational in any node editor. At the same time, there's [a design discussion](https://projects.blender.org/blender/blender/issues/111438) to make this a native function to Blender, named "Swap Node" operator. Since it's not functional anymore and the alternative will be a native one anyway, I think Switch Type function should be removed from Node Wrangler in 4.0.
Author
Contributor

Well this is a suggestion for removal.

2d53c4b81b

I suggest to remove the function, show this notice of removal when Shift + S shortcut was used.

switch_type_warning.png

Well this is a suggestion for removal. https://projects.blender.org/persun/blender-addons/commit/2d53c4b81b868d5998993de5183abefdbcd46f3c I suggest to remove the function, show this notice of removal when `Shift + S` shortcut was used. ![switch_type_warning.png](/attachments/d4b31fd1-9e44-47be-97b8-96610740b70e)
Hans Goudey changed title from Node Wrangler: Switch Type shows empty menu in Geometry Nodes to Node Wrangler: Switch Type shows empty menu 2023-10-19 09:47:00 +02:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
11 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-addons#101514
No description provided.