# Using data with python nodes

I have created a number of python nodes inside my own tree. I have one node that takes one input and has a button called "Simulate". This is an operator that is held in another file. Currently all it does is print some text.

The code for my output node is:

class SimulateNode(Node, CrowdMasterTreeNode):
'''The simulate node'''
bl_idname = 'SimulateNode'
bl_label = 'Simulate'
bl_icon = 'SOUND'

def init(self, context):
self.inputs.new('CrowdSocketType', "Crowd")

def copy(self, node):
print("Copying from node ", node)

def free(self):
print("Removing node ", self, ", Goodbye!")

def draw_buttons(self, context, layout):
layout.enabled = False
layout.scale_y = 1.5
layout.operator("scene.cm_run_simulation", icon_value=cicon('run_sim'))

def draw_buttons_ext(self, context, layout):
layout.operator("scene.cm_run_simulation", icon_value=cicon('run_sim'))

def draw_label(self):
return "Simulate"


I have an input node that supplies an integer:

class IntegerNode(Node, CrowdMasterTreeNode):
'''The integer node'''
bl_idname = 'IntegerNode'
bl_label = 'Integer'
bl_icon = 'SOUND'

Integer = bpy.props.IntProperty(default=3)

def init(self, context):
self.outputs.new('NodeSocketInt', "Integer")

def copy(self, node):
print("Copying from node ", node)

def free(self):
print("Removing node ", self, ", Goodbye!")

def draw_buttons(self, context, layout):
layout.prop(self, "Integer")

def draw_buttons_ext(self, context, layout):
layout.prop(self, "Integer")

def draw_label(self):
return "Integer"


How can I pass any data from any node connected to that output node to the operator?

• The integer node doesn't send data, your sim node gets the data it needs. This might be what you are after and this answer expands some updating options. – sambler Jul 12 '16 at 13:49
• I need to push the data from each node connected to that operator – John Roper Jul 12 '16 at 16:11
• When you run your simulation, it needs to read the data that connected nodes have available. Loop over all input sockets and get the value from the connected node then use it in your calculations. The animation nodes and sverchok are the best examples that you can look at. – sambler Jul 12 '16 at 17:05
• How do I access the input sockets? – John Roper Jul 12 '16 at 22:37
• It's in the first link I gave. – sambler Jul 13 '16 at 6:06