Post #2016: : post_02028
🏷️ Tags
macro shader-editor advanced solved
⚙️ Related PME Features
- 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:
-
You can create a new macro (download) and use it in your toolbar buttons (
Commandtab):
open_menu('Add Node Macro', node_type="ShaderNodeTexNoise")
-
Or just use this code in toolbar buttons (
Commandtab):
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