Post #2016: ![](https://blenderartists.org/user_avatar/blenderartists.org/pinhead/48/528486_

📋 Metadata

🏷️ Tags

macro shader-editor advanced solved

  • Macro Editor
  • Popup Dialog Editor
  • Python Scripting
  • Custom Commands

💬 Content

Pinhead:

i want to create top toolbar in shader editor:

bpy.ops.node.add_node(type='ShaderNodeTexNoise', use_transform=True)

Hi, @Pinhead
This tool requires Node Editor Area to be active.

Download and copy this patch to scripts/addons/pie_menu_editor folder and restart Blender.
The patch adds focus_area() function which will be useful for your toolbar.

Now you have 2 ways to fix the tool:

  1. You can create a new macro (download) and use it in your toolbar buttons (Command tab):

open_menu('Add Node Macro', node_type="ShaderNodeTexNoise")
  1. Or just use this code in toolbar buttons (Command tab):

node_type = "ShaderNodeTexNoise"; focus_area('NODE_EDITOR', center=False); bpy.ops.pme.timeout(cmd="bpy.ops.node.add_node(override_context(area='NODE_EDITOR', region='WINDOW'), type='%s', use_transform=False); bpy.ops.node.translate_attach_remove_on_cancel(override_context(area='NODE_EDITOR', region='WINDOW'), 'INVOKE_DEFAULT', True)" % node_type)

❤️ 2 likes


🔗 View on Blender Artists