Page MenuHome

Node Wrangler: Use utility function to populate switch menu
Needs ReviewPublic

Authored by Scott Ramsay (smramsay) on Tue, Mar 10, 1:51 AM.
Tags
None
Subscribers
None
Tokens
"100" token, awarded by EAW."Party Time" token, awarded by lichtwerk."Like" token, awarded by brecht.

Details

Summary

Currently, the nodes in the Switch menu (Shift+S) are generated from Node Wrangler's own long static list of categories and nodes.
A lack of updates to the list meant it was missing some nodes.
Cycles was still missing the Principled Hair BSDF, Principled Volume, and AOV Output.
A lack of context meant it was also possible to switch to nodes incompatible with the current engine.
Like EEVEE having many shaders from Cycles that aren't in it's regular Add menu.
Though if people like that 'feature', this diff should be rejected.

This changes to using the node_categories_iter utility which uses the correct list of available nodes from nodeitems_builtins.py.

The submenu classes are now procedurally generated and registered in the same fashion as the add menu, but just with a different operator in their draw function.

Removing the static lists required a couple changes outside of the Switch menu.
Mostly having to compare types using the verbose node.rna_type.identifier.

Diff Detail

Event Timeline

Scott Ramsay (smramsay) updated this revision to Diff 22663.EditedWed, Mar 11, 8:22 AM

Procedurally generate and register the Switch category submenus instead of keeping class stubs.
The only downside of this I've found is that external render engines that register custom node categories (like Radeon ProRender) must be enabled before Node Wrangler or the switch menu will be empty and print errors to the console.

Scott Ramsay (smramsay) edited the summary of this revision. (Show Details)Wed, Mar 11, 4:10 PM

Updated naming to be slightly more clear

"Handle" the error caused by third-party engines changing the node lists after Node Wrangler is enabled.
Instead of displaying a blank menu and printing errors to the console, display a message asking the user to re-enable Node Wrangler.
Ideally I'd just re-enable it automatically, but I've no idea how to do that.

Also duplicated a bit of code to only filter out the Frame node from the Layout menu.