manipulating nodes with python blender 2.5

hallo together,
i am trying to manipolate my composition nodes with python.
for example setting color to other values and such a stuff.

so i relaised that there are the types: bpy.types.CompositorNodes
but how can i get a specific node?

can someone point me to an example on how to do it?

check the API DOCS

i did this, but cant find a way to select the nodes. meshes have names, but nodes dont have. or did i miss something?

this is what i got for doing the sepia render with compositing nodes
but i guess the same can be done for mat and texture nodes too

wish there was an example for these !
if you do show us what you do as an example

good luck

thanks happy 2.5

i managed to understand the basic node setup with python:

import bpy, math
# switch on nodes
bpy.context.scene.use_nodes = True
tree = bpy.context.scene.node_tree

# clear default nodes
for n in tree.nodes:

# create input render layer  node
rl ='R_LAYERS')      
rl.location = 0,0

# create HUE_SAT node
hs ='HUE_SAT')     
hs.location = 200,0
# change value

# create output node
comp ='COMPOSITE')   
comp.location = 400,0

# link nodes
links = tree.links
link0 =[0],hs.inputs[1])
link1 =[0],comp.inputs[0])

is there a way to get the path of existing nodes without creating it?
how can i change the values of the default_value for example in the invert node?

invert.default_value = 0.3

is not working.

i mean this Fac value

inv = tree.nodes['Invert'] #gets the already existing invert node by name
inv.inputs[0].default_value = [0.3]
# or inv.inputs['Fac'].default_value = [0.3]

this is realy simple. awsome. thanks for the snippet.
i was searching for something dificult, but blender does it the easy way.
also i thought the names wich are standing ontop of the nodes are just names of the effect, but now i realize thet when i add another node of the same type it got an suffix like nodename.000 so i can call it directly. awsome. thanks a lot.

Not completely on topic but just a related question: does anyone know how to get the output value from a node in python? I try for example:[’Scene’].node_tree[‘Levels.001’].outputs[‘Mean’]

but it doesn’t output this as a float, which is what I would have expected. Any ideas? :confused:

Try this:[’Scene’].node_tree[‘Levels.001’].outputs[‘Mean’].default_value[0]

Thanks cmomoney but that only displays the default output value (0.0 in this case). Any ideas how to get the output from my image?

Unfortunatley it doesn’t work that way, the in/outputs for the sockets aren’t stored in a way that python can get at them.

Ah, that’s a shame. Is there any way to access results from the compositor or only the render result?

I realize I’m digging up an old thread, but I figured this directly relates to my current situation, and I can’t find a thread more updated, and figured better than starting a new one for an issue that has already come up.

So, is this still the case, that we cannot access Node Sockets with Python? Seems incredibly important to the further advancement of Cycles, but all the stuff in this thread is the same information I’m finding everywhere else.

Nope, still the same…

Not sure how (or if even) pynodes are going to deal with this but they’ll certainly need it if they have an exec() function.