Accessing Node Properties using Python?
Forum rules
Please upload a testscene that allows developers to reproduce the problem, and attach some images.
Please upload a testscene that allows developers to reproduce the problem, and attach some images.
- Lights_and_Shadows
- Posts: 47
- Joined: Thu Jan 18, 2018 3:40 pm
- Location: United States
Accessing Node Properties using Python?
I remember in the old LuxRender we could access the specific nodes using Luxrender-specific keywords. Is that still possible? I've been attempting to change colors using a script and so far I've had no success.
Windows 7 Professional, x64
Intel Core i7 6700K, 4GHz
EVGA GeForce GT740 Superclocked, 4GB GDDR5
32GB RAM DDR4 (approx. 80GB with pagefile active)
RAID 0 configured HDD setup (2x 500GB Seagate Barracudas)
Intel Core i7 6700K, 4GHz
EVGA GeForce GT740 Superclocked, 4GB GDDR5
32GB RAM DDR4 (approx. 80GB with pagefile active)
RAID 0 configured HDD setup (2x 500GB Seagate Barracudas)
Re: Accessing Node Properties using Python?
Yes it's perfectly possible.
What exactly do you want to do?
What exactly do you want to do?
- Lights_and_Shadows
- Posts: 47
- Joined: Thu Jan 18, 2018 3:40 pm
- Location: United States
Re: Accessing Node Properties using Python?
I have a series of Mix nodes for RGB colors, about 9 in total - a group of 8, four of which are for diffuse, the other four for specular highlights. The last one is for emission. I know how to do it for Cycles no issues, but I don't know how to point to LuxCore specifically. All I am trying to do is take the "Color 2" RGB values from each of those nodes, and replace them with another value, but doing it from a script instead of in the Node Editor itself. It's so I can have some form of color preset, if you will.
Windows 7 Professional, x64
Intel Core i7 6700K, 4GHz
EVGA GeForce GT740 Superclocked, 4GB GDDR5
32GB RAM DDR4 (approx. 80GB with pagefile active)
RAID 0 configured HDD setup (2x 500GB Seagate Barracudas)
Intel Core i7 6700K, 4GHz
EVGA GeForce GT740 Superclocked, 4GB GDDR5
32GB RAM DDR4 (approx. 80GB with pagefile active)
RAID 0 configured HDD setup (2x 500GB Seagate Barracudas)
Re: Accessing Node Properties using Python?
It's actually very similar to Cycles nodes.
Just that to access the node tree, you have to call material.luxcore.node_tree.
If you want to change a socket value, get the socket from node.inputs, then call its default_value attribute (it holds the value of the socket when no node is linked to it).
I hope the example image helps. Also the console is a big help to explore this interactively.
If you have further questions, feel free to ask.
Just that to access the node tree, you have to call material.luxcore.node_tree.
If you want to change a socket value, get the socket from node.inputs, then call its default_value attribute (it holds the value of the socket when no node is linked to it).
I hope the example image helps. Also the console is a big help to explore this interactively.
If you have further questions, feel free to ask.
- Lights_and_Shadows
- Posts: 47
- Joined: Thu Jan 18, 2018 3:40 pm
- Location: United States
Re: Accessing Node Properties using Python?
Ahh, that was all I needed. Thanks, B.Y.O.B I know where to go from here. It now sees my nodes.
Windows 7 Professional, x64
Intel Core i7 6700K, 4GHz
EVGA GeForce GT740 Superclocked, 4GB GDDR5
32GB RAM DDR4 (approx. 80GB with pagefile active)
RAID 0 configured HDD setup (2x 500GB Seagate Barracudas)
Intel Core i7 6700K, 4GHz
EVGA GeForce GT740 Superclocked, 4GB GDDR5
32GB RAM DDR4 (approx. 80GB with pagefile active)
RAID 0 configured HDD setup (2x 500GB Seagate Barracudas)
Re: Accessing Node Properties using Python?
In case you want to iterate over all nodes in a tree by type, look into the nodes folder in the addon.
for example, the material node types:
https://github.com/LuxCoreRender/BlendL ... t__.py#L10
So you can do stuff like
for example, the material node types:
https://github.com/LuxCoreRender/BlendL ... t__.py#L10
So you can do stuff like
Code: Select all
for node in node_tree.nodes:
if node.bl_idname == "LuxCoreNodeMatMix":
... # Do stuff with all mix material nodes