How do I get the Color value from an RGB node with Python?Python script to print tooltip value when mouse is...

Bitcoin automatically diverted to bech32 address

How quickly could a motion be passed to alter minimum age for POTUS?

Is it illegal to infringe copyright if your boss or your client ordered you to do it?

Why Third *Reich*? Why is "reich" not translated when "Dritten" is? What is the English synonym of reich? Realm?

Is 'bad luck' with former employees a red flag?

How to explain one side of Super Earth is smoother than the other side?

How to make clear what a part-humanoid character looks like when they're quite common in their world?

Should I update trigger API version?

Why does the includeonly command not stepcounter the chaptercounter for omitted chapters?

How to create a cover page like this?

How aware are characters of their class in-universe?

Bacterial growth inhibitors used in Deodorants

Why do atoms emit a certain colour of light? (The emission spectra)

Google tag assistant reports: "Same web property ID is tracked twice"

Can "so" express a reason not a result?

Does an increasing sequence of reals converge if the difference of consecutive terms approaches zero?

A dragon's soul trapped in a ring of mind shielding wants a new body; what magic could enable her to do so?

Why is it a problem for Freddie if the guys from Munich did what he wanted?

Arbitrary Interval Ruler

Is this an email from Apple or fraud?

The concept of infinity for a 5 year old

US ESTA Question confusion

Structure of pyrophosphorous acid

Animate an airplane in Beamer



How do I get the Color value from an RGB node with Python?


Python script to print tooltip value when mouse is over a propertyError after script selects object and tries to change to “EDIT” modeHow to control RGB color input via python scriptis there a way to streamline scripting these shaders and modifier keyframes?Use ID properties in cycles/nodesHow to get Color and Z-Depth from Viewer Node?Setting all default_values of nodes to 0 does not result in expected black outputHow would I get brighter color with the voronoi node?Python - get RGB value from face with generated textureRead shader node data from *.blender file by using external pythonGet Hex triplet for color and real 256 RGB from diffuse Color using pythonProcedural volumetric texture generated from a scriptHow to get material parameter by name, and check if texture is assigned to parameterHow to control RGB color input via python script













6












$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?



enter image description here










share|improve this question









New contributor




UlfR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$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
    17 hours ago
















6












$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?



enter image description here










share|improve this question









New contributor




UlfR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$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
    17 hours ago














6












6








6


1



$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?



enter image description here










share|improve this question









New contributor




UlfR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$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?



enter image description here







python scripting nodes






share|improve this question









New contributor




UlfR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




UlfR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 22 hours ago









Ray Mairlot

22.3k56395




22.3k56395






New contributor




UlfR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 23 hours ago









UlfRUlfR

1334




1334




New contributor




UlfR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





UlfR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






UlfR is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • $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
    17 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
    17 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
17 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
17 hours ago










2 Answers
2






active

oldest

votes


















10












$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.



tooltip



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)





share|improve this answer









$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
    22 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
    22 hours ago






  • 1




    $begingroup$
    You can also access the individual values directly from the bpy_prop_array via their indices, such as def_rgb[0].
    $endgroup$
    – Leander
    12 hours ago





















6












$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



How to get data access to the data path






share|improve this answer











$endgroup$













    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.










    draft saved

    draft discarded


















    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









    10












    $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.



    tooltip



    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)





    share|improve this answer









    $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
      22 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
      22 hours ago






    • 1




      $begingroup$
      You can also access the individual values directly from the bpy_prop_array via their indices, such as def_rgb[0].
      $endgroup$
      – Leander
      12 hours ago


















    10












    $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.



    tooltip



    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)





    share|improve this answer









    $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
      22 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
      22 hours ago






    • 1




      $begingroup$
      You can also access the individual values directly from the bpy_prop_array via their indices, such as def_rgb[0].
      $endgroup$
      – Leander
      12 hours ago
















    10












    10








    10





    $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.



    tooltip



    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)





    share|improve this answer









    $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.



    tooltip



    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)






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered 22 hours ago









    LeanderLeander

    12.2k11550




    12.2k11550












    • $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
      22 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
      22 hours ago






    • 1




      $begingroup$
      You can also access the individual values directly from the bpy_prop_array via their indices, such as def_rgb[0].
      $endgroup$
      – Leander
      12 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
      22 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
      22 hours ago






    • 1




      $begingroup$
      You can also access the individual values directly from the bpy_prop_array via their indices, such as def_rgb[0].
      $endgroup$
      – Leander
      12 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
    22 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
    22 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
    22 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
    22 hours ago




    1




    1




    $begingroup$
    You can also access the individual values directly from the bpy_prop_array via their indices, such as def_rgb[0].
    $endgroup$
    – Leander
    12 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
    12 hours ago















    6












    $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



    How to get data access to the data path






    share|improve this answer











    $endgroup$


















      6












      $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



      How to get data access to the data path






      share|improve this answer











      $endgroup$
















        6












        6








        6





        $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



        How to get data access to the data path






        share|improve this answer











        $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



        How to get data access to the data path







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 22 hours ago

























        answered 22 hours ago









        miceterminatormiceterminator

        1,95621124




        1,95621124






















            UlfR is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            ORA-01691 (unable to extend lob segment) even though my tablespace has AUTOEXTEND onORA-01692: unable to...

            Always On Availability groups resolving state after failover - Remote harden of transaction...

            Circunscripción electoral de Guipúzcoa Referencias Menú de navegaciónLas claves del sistema electoral en...