Blender Python Tutorial : Create Custom Node Group [learn python for beginners]

preview_player
Показать описание
In this Blender Python Tutorial, we will be creating a Custom Node Group (for the compositor) with Python. Custom Node Groups are essentially a bunch of nodes grouped together inside a single node.

Looking to learn Python for beginners? You are in the right place. Be sure to check out the Scripting Playlist!.

If you want to download the Finished Template you can find the link in our blog.

We first need to create a test panel and then we can define the Custom Node Group, then we can tie it all in with an operator. If you followed along in the previous videos, you will have everything you need to get started.

I hope you found this Blender Python Tutorial helpful and as always thanks for watching!

Рекомендации по теме
Комментарии
Автор

FYI, from Blender 4.0 onwards you will get "AttributeError: 'CompositorNodeTree' object has no attribute 'inputs'" error when creating a new socket with the given codes. For example line 30 needs to replace from "test_group.inputs.new('NodeSocketFloat', 'Factor Value')" to Value", in_out='INPUT')".

SamLau
Автор

Nice tutorial.
In case someone wants to do this with a ShaderNodeGroup in the Shading-Editor, then he needs to change the python-script to the following:
def execute(self, context):
custom_node_name = "Test Node"
my_group = create_test_group(self, context, custom_node_name)
node_tree =
new_node =
new_node.node_tree =
new_node.use_custom_color = True
new_node.color = (0.5, 0.4, 0.3)
return {"FINISHED"}
I had to get the from the current context, otherwhise context.scene.node_tree will be of NoneType.

roberth
Автор

Darkfall, I keep looking up questions and your videos always come up and typically have the answer. that is a Subscribe

angzarrpsyco
Автор

Hello Sir.Your addon creation tutorials are wonderful and easy to follow.🎉
Already getting a tonne of experience from your teaching.❤

I have something to ask: I tried doing this in the Shader Editor but keep getting an error that the attribute 'ShaderNodeTree' is not recognized. I'm using Blender 2.9. what could be the problem?

AnimatorBlender
Автор

Since Blender 4.0, getting this error: AttributeError: 'CompositorNodeTree' object has no attribute 'inputs'. This is due to a change in the API. The new format is:
For inputs:
Value', in_out= 'INPUT', socket_type= 'NodeSocketFloat')
Input', in_out='INPUT', socket_type= 'NodeSocketColor')

Similarly for output:
test_group.interface.new_socket(name='Output', in_out='OUTPUT', socket_type= 'NodeSocketColor')

RitwikVaidya
Автор

might you show how to make an empty node and how to add it to a node tree, thanks for share your videos

pasionporblender
Автор

awesome, how can we get the existing shader details as a python script so then we can add that shader in another project with the help of python script?

KriGeta
Автор

Another tutorial behind me and thank you again. What I notices here and before too but decided to ask the question now, that nodes locations are hard to match based on this what is shown in compositor while you moving each node on x, y axis, the same in info panel, one you move the node, the info panel shown the code and coordination, when you paste those values into code and run the script, the results show the nodes in completely different places you want them to be.

seeboo
Автор

I'm just glad you're not whispering like that other dude.

nuca
Автор

Thanks for your tutorials I really appreciate them!
Will try to get my node groups as an addon too.
I'm actually working on node trees to to have a slight approach to something kinda "Substance Designer". I got inspired by "Nodevember" especially from Simon Thommes. I'm trying to learn bit more Python to code custum nodes to even create more Shapes. Keep up your great work!

cultless
Автор

works perfectly!.
Do you know how to (get the which node is connected to a (material output) using python)

smtsudipta
Автор

NOICE, BRO! Keep 'em coming, please! <3 <3 <3 <3

franciscoicarocs
Автор

When I try to run the script, it says in the system console: rna_uiItemO: operator missing srna 'node.mist_operator'. What does it mean?

standingpad
Автор

I can run the script successfully in 2.91 but it doesn't show the Panel with the "Adding Node" button. Is there any way that I can do in order to show the Panel?

kaylaman
Автор

Thanks for your tutorials bro ! do you know how to add an already defined shaderNodeGroup to a material with python api?

Cat_trot
Автор

hello, the tutorial is awesome, bt I cant understand whats happening from line 65 of your script. If you can explain me in short it would be a lot of help. Thanks in advance

codcdevil
Автор

is it possible to control value inside geo node from outside of project ?

sanketsbrush
Автор

So I've got a script that uses bpy.data.node_groups to copy all the nodes in a material and make it into a context free node group since I am trying to take user custom materials on the fly and mix them with a user specified material. One issue though is the Nodegroups the script generates don't have any kind of output sockets to send all the material data to the material output and it doesn't let me link the shader to the material output by hand even since no socket there. Do you know a way to add sockets to the node group?

shredmancer
Автор

how to set the default range in custom group

smtsudipta
Автор

how can i find out the location of a node in the editor?

BreadcrumbMC