How do I get the Color value from an RGB node with Python?
$begingroup$
I'm a seasoned programmer, but fairly new to blender and 3D-modeling in general. So to get an understanding of different properties I want to write python scripts to create multiple renderings with different settings of various values.
In the example below I have figured out how to change the Volume Absorption Density, ex:
bpy.data.materials['MyMaterial'].node_tree.nodes['Volume Absorption'].inputs['Density'].default_value = 100
But not the RGB-node. It seems I cant even get the current values out of it. Some things I have tried:
bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].color
bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].color.r
bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].color.outputs['Color']
How do I get and set output values of the RGB-node in py python-script?
python scripting nodes
New contributor
$endgroup$
add a comment |
$begingroup$
I'm a seasoned programmer, but fairly new to blender and 3D-modeling in general. So to get an understanding of different properties I want to write python scripts to create multiple renderings with different settings of various values.
In the example below I have figured out how to change the Volume Absorption Density, ex:
bpy.data.materials['MyMaterial'].node_tree.nodes['Volume Absorption'].inputs['Density'].default_value = 100
But not the RGB-node. It seems I cant even get the current values out of it. Some things I have tried:
bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].color
bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].color.r
bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].color.outputs['Color']
How do I get and set output values of the RGB-node in py python-script?
python scripting nodes
New contributor
$endgroup$
$begingroup$
just fyi here's a script showing how you can build your nodes directly from python: blender.stackexchange.com/q/35436/5334 and here's another blender.stackexchange.com/q/34609/5334
$endgroup$
– uhoh
8 hours ago
add a comment |
$begingroup$
I'm a seasoned programmer, but fairly new to blender and 3D-modeling in general. So to get an understanding of different properties I want to write python scripts to create multiple renderings with different settings of various values.
In the example below I have figured out how to change the Volume Absorption Density, ex:
bpy.data.materials['MyMaterial'].node_tree.nodes['Volume Absorption'].inputs['Density'].default_value = 100
But not the RGB-node. It seems I cant even get the current values out of it. Some things I have tried:
bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].color
bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].color.r
bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].color.outputs['Color']
How do I get and set output values of the RGB-node in py python-script?
python scripting nodes
New contributor
$endgroup$
I'm a seasoned programmer, but fairly new to blender and 3D-modeling in general. So to get an understanding of different properties I want to write python scripts to create multiple renderings with different settings of various values.
In the example below I have figured out how to change the Volume Absorption Density, ex:
bpy.data.materials['MyMaterial'].node_tree.nodes['Volume Absorption'].inputs['Density'].default_value = 100
But not the RGB-node. It seems I cant even get the current values out of it. Some things I have tried:
bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].color
bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].color.r
bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].color.outputs['Color']
How do I get and set output values of the RGB-node in py python-script?
python scripting nodes
python scripting nodes
New contributor
New contributor
edited 13 hours ago
Ray Mairlot
22.3k56395
22.3k56395
New contributor
asked 15 hours ago
UlfRUlfR
1284
1284
New contributor
New contributor
$begingroup$
just fyi here's a script showing how you can build your nodes directly from python: blender.stackexchange.com/q/35436/5334 and here's another blender.stackexchange.com/q/34609/5334
$endgroup$
– uhoh
8 hours ago
add a comment |
$begingroup$
just fyi here's a script showing how you can build your nodes directly from python: blender.stackexchange.com/q/35436/5334 and here's another blender.stackexchange.com/q/34609/5334
$endgroup$
– uhoh
8 hours ago
$begingroup$
just fyi here's a script showing how you can build your nodes directly from python: blender.stackexchange.com/q/35436/5334 and here's another blender.stackexchange.com/q/34609/5334
$endgroup$
– uhoh
8 hours ago
$begingroup$
just fyi here's a script showing how you can build your nodes directly from python: blender.stackexchange.com/q/35436/5334 and here's another blender.stackexchange.com/q/34609/5334
$endgroup$
– uhoh
8 hours ago
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
Welcome to Blender.SE, UlfR.
Finding out a property in Blender is relatively easy. Make sure, you have python tooltips enabled (in the user preferences).
Then hover your mouse cursor over the property (in this case the color). A tooltip containing the python command will appear.
The property you seek seems to be outputs[0].default_value
.
def_rgb = bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].outputs[0].default_value
It is a bpy_prop_array
by default, so you may want to convert it to a list.
float_values = list(def_rgb)
$endgroup$
$begingroup$
Miceterminator beat me to it by 3 minutes. I will leave this answer up, as it mentions the python tooltip and his doesn't you could accept his answer as the correct one however.
$endgroup$
– Leander
13 hours ago
$begingroup$
my problem was that bpy.data.materials[1].node_tree.nodes['RGB'].outputs[0].default_value = (1.0,1.0,0.5,1.0) works but bpy.data.materials[1].node_tree.nodes['RGB'].outputs[0].default_value produces nothing in the Python console. Converting it to list then displayed the hidden values.
$endgroup$
– rob
13 hours ago
$begingroup$
You can also access the individual values directly from thebpy_prop_array
via their indices, such asdef_rgb[0]
.
$endgroup$
– Leander
3 hours ago
add a comment |
$begingroup$
As you already found you way to the node tree, the "Copy data path" option is generally very helpful:
Right click on the field you want to access and use the "Copy data path" option.
bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].outputs[0].default_value
You can also look at the answers here and here
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "502"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
UlfR is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fblender.stackexchange.com%2fquestions%2f132142%2fhow-do-i-get-the-color-value-from-an-rgb-node-with-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Welcome to Blender.SE, UlfR.
Finding out a property in Blender is relatively easy. Make sure, you have python tooltips enabled (in the user preferences).
Then hover your mouse cursor over the property (in this case the color). A tooltip containing the python command will appear.
The property you seek seems to be outputs[0].default_value
.
def_rgb = bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].outputs[0].default_value
It is a bpy_prop_array
by default, so you may want to convert it to a list.
float_values = list(def_rgb)
$endgroup$
$begingroup$
Miceterminator beat me to it by 3 minutes. I will leave this answer up, as it mentions the python tooltip and his doesn't you could accept his answer as the correct one however.
$endgroup$
– Leander
13 hours ago
$begingroup$
my problem was that bpy.data.materials[1].node_tree.nodes['RGB'].outputs[0].default_value = (1.0,1.0,0.5,1.0) works but bpy.data.materials[1].node_tree.nodes['RGB'].outputs[0].default_value produces nothing in the Python console. Converting it to list then displayed the hidden values.
$endgroup$
– rob
13 hours ago
$begingroup$
You can also access the individual values directly from thebpy_prop_array
via their indices, such asdef_rgb[0]
.
$endgroup$
– Leander
3 hours ago
add a comment |
$begingroup$
Welcome to Blender.SE, UlfR.
Finding out a property in Blender is relatively easy. Make sure, you have python tooltips enabled (in the user preferences).
Then hover your mouse cursor over the property (in this case the color). A tooltip containing the python command will appear.
The property you seek seems to be outputs[0].default_value
.
def_rgb = bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].outputs[0].default_value
It is a bpy_prop_array
by default, so you may want to convert it to a list.
float_values = list(def_rgb)
$endgroup$
$begingroup$
Miceterminator beat me to it by 3 minutes. I will leave this answer up, as it mentions the python tooltip and his doesn't you could accept his answer as the correct one however.
$endgroup$
– Leander
13 hours ago
$begingroup$
my problem was that bpy.data.materials[1].node_tree.nodes['RGB'].outputs[0].default_value = (1.0,1.0,0.5,1.0) works but bpy.data.materials[1].node_tree.nodes['RGB'].outputs[0].default_value produces nothing in the Python console. Converting it to list then displayed the hidden values.
$endgroup$
– rob
13 hours ago
$begingroup$
You can also access the individual values directly from thebpy_prop_array
via their indices, such asdef_rgb[0]
.
$endgroup$
– Leander
3 hours ago
add a comment |
$begingroup$
Welcome to Blender.SE, UlfR.
Finding out a property in Blender is relatively easy. Make sure, you have python tooltips enabled (in the user preferences).
Then hover your mouse cursor over the property (in this case the color). A tooltip containing the python command will appear.
The property you seek seems to be outputs[0].default_value
.
def_rgb = bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].outputs[0].default_value
It is a bpy_prop_array
by default, so you may want to convert it to a list.
float_values = list(def_rgb)
$endgroup$
Welcome to Blender.SE, UlfR.
Finding out a property in Blender is relatively easy. Make sure, you have python tooltips enabled (in the user preferences).
Then hover your mouse cursor over the property (in this case the color). A tooltip containing the python command will appear.
The property you seek seems to be outputs[0].default_value
.
def_rgb = bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].outputs[0].default_value
It is a bpy_prop_array
by default, so you may want to convert it to a list.
float_values = list(def_rgb)
answered 13 hours ago
LeanderLeander
12.2k11549
12.2k11549
$begingroup$
Miceterminator beat me to it by 3 minutes. I will leave this answer up, as it mentions the python tooltip and his doesn't you could accept his answer as the correct one however.
$endgroup$
– Leander
13 hours ago
$begingroup$
my problem was that bpy.data.materials[1].node_tree.nodes['RGB'].outputs[0].default_value = (1.0,1.0,0.5,1.0) works but bpy.data.materials[1].node_tree.nodes['RGB'].outputs[0].default_value produces nothing in the Python console. Converting it to list then displayed the hidden values.
$endgroup$
– rob
13 hours ago
$begingroup$
You can also access the individual values directly from thebpy_prop_array
via their indices, such asdef_rgb[0]
.
$endgroup$
– Leander
3 hours ago
add a comment |
$begingroup$
Miceterminator beat me to it by 3 minutes. I will leave this answer up, as it mentions the python tooltip and his doesn't you could accept his answer as the correct one however.
$endgroup$
– Leander
13 hours ago
$begingroup$
my problem was that bpy.data.materials[1].node_tree.nodes['RGB'].outputs[0].default_value = (1.0,1.0,0.5,1.0) works but bpy.data.materials[1].node_tree.nodes['RGB'].outputs[0].default_value produces nothing in the Python console. Converting it to list then displayed the hidden values.
$endgroup$
– rob
13 hours ago
$begingroup$
You can also access the individual values directly from thebpy_prop_array
via their indices, such asdef_rgb[0]
.
$endgroup$
– Leander
3 hours ago
$begingroup$
Miceterminator beat me to it by 3 minutes. I will leave this answer up, as it mentions the python tooltip and his doesn't you could accept his answer as the correct one however.
$endgroup$
– Leander
13 hours ago
$begingroup$
Miceterminator beat me to it by 3 minutes. I will leave this answer up, as it mentions the python tooltip and his doesn't you could accept his answer as the correct one however.
$endgroup$
– Leander
13 hours ago
$begingroup$
my problem was that bpy.data.materials[1].node_tree.nodes['RGB'].outputs[0].default_value = (1.0,1.0,0.5,1.0) works but bpy.data.materials[1].node_tree.nodes['RGB'].outputs[0].default_value produces nothing in the Python console. Converting it to list then displayed the hidden values.
$endgroup$
– rob
13 hours ago
$begingroup$
my problem was that bpy.data.materials[1].node_tree.nodes['RGB'].outputs[0].default_value = (1.0,1.0,0.5,1.0) works but bpy.data.materials[1].node_tree.nodes['RGB'].outputs[0].default_value produces nothing in the Python console. Converting it to list then displayed the hidden values.
$endgroup$
– rob
13 hours ago
$begingroup$
You can also access the individual values directly from the
bpy_prop_array
via their indices, such as def_rgb[0]
.$endgroup$
– Leander
3 hours ago
$begingroup$
You can also access the individual values directly from the
bpy_prop_array
via their indices, such as def_rgb[0]
.$endgroup$
– Leander
3 hours ago
add a comment |
$begingroup$
As you already found you way to the node tree, the "Copy data path" option is generally very helpful:
Right click on the field you want to access and use the "Copy data path" option.
bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].outputs[0].default_value
You can also look at the answers here and here
$endgroup$
add a comment |
$begingroup$
As you already found you way to the node tree, the "Copy data path" option is generally very helpful:
Right click on the field you want to access and use the "Copy data path" option.
bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].outputs[0].default_value
You can also look at the answers here and here
$endgroup$
add a comment |
$begingroup$
As you already found you way to the node tree, the "Copy data path" option is generally very helpful:
Right click on the field you want to access and use the "Copy data path" option.
bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].outputs[0].default_value
You can also look at the answers here and here
$endgroup$
As you already found you way to the node tree, the "Copy data path" option is generally very helpful:
Right click on the field you want to access and use the "Copy data path" option.
bpy.data.materials['MyMaterial'].node_tree.nodes['RGB'].outputs[0].default_value
You can also look at the answers here and here
edited 13 hours ago
answered 13 hours ago
miceterminatormiceterminator
1,94621124
1,94621124
add a comment |
add a comment |
UlfR is a new contributor. Be nice, and check out our Code of Conduct.
UlfR is a new contributor. Be nice, and check out our Code of Conduct.
UlfR is a new contributor. Be nice, and check out our Code of Conduct.
UlfR is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Blender Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fblender.stackexchange.com%2fquestions%2f132142%2fhow-do-i-get-the-color-value-from-an-rgb-node-with-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
just fyi here's a script showing how you can build your nodes directly from python: blender.stackexchange.com/q/35436/5334 and here's another blender.stackexchange.com/q/34609/5334
$endgroup$
– uhoh
8 hours ago