I'm trying to access the keys of a particular node of inputs and outputs. to access the use property keys:
n = my_node #(From node_tree.nodes)
for key in n.bl_rna.properties.keys():
attributes = getattr(n, key)
now I would like to access the attributes of n.inputs and n.outputs
but this does not produce any results:
for key in n.outputs.bl_rna.properties.keys():
attributes = getattr(n.outputs, key)
I'm pretty confused about this, I'm probably wrong
Edit: For more details, this would serve to copy the nodes and their properties. But when I have to access the inputs and outputs properties I have difficulties at the moment, post a small test that I am running, for now it does not work properly, but perhaps it makes better understand what I am trying to do
for n in bpy.context.scene.node_tree.nodes:
tipo_di_nodo = n.bl_rna.identifier ##Ty @batFINGER
nodo_copiato = bpy.context.scene.node_tree.nodes.new(tipo_di_nodo)
#This copies the node exactly, with some data
for key in n.bl_rna.properties.keys():
source_attribute = getattr(n, key)
if not n.is_property_readonly(key):
setattr(nodo_copiato, key, source_attribute)
#I would like it to copy and assign value inputs
#For now this is not working
for val in n.inputs.values():
for key in val.bl_rna.properties.keys():
in_source_attribute = getattr(val,key)
if not val.is_property_readonly(key):
setattr(nodo_copiato, key, in_source_attribute)
Note: I want to clarify, because i don't want to create further confusion, that the question is not "How to copy an entire tree of nodes" but is how to access the values n.inputs [#].default_values (and other) in complete automation, as it is done in the line of my code in the part where the attributes are set via setattr / getattr As I want to get there by myself to the copy of a tree of knots, I am trying to study the situation, trying to better understand Blender's API thanks to the help of the community
tipo_di_nodo = n.bl_rna.identifierEnjoying getting my Aussie accent around the Espanol – batFINGER Jan 24 '20 at 04:310. There is no way to "reset" the values of any node and you have to create a new node to get the default values anyway... and really, the API of the node editor isn't the greatest part @Pastrokkio – brockmann Jan 24 '20 at 09:45