3
$\begingroup$

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):
    if self.inputs['Crowd'].is_linked == False:
        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"

integer input and crowd output nodes

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

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – sambler Jul 12 '16 at 13:49
  • $\begingroup$ I need to push the data from each node connected to that operator $\endgroup$ – John Roper Jul 12 '16 at 16:11
  • $\begingroup$ 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. $\endgroup$ – sambler Jul 12 '16 at 17:05
  • $\begingroup$ How do I access the input sockets? $\endgroup$ – John Roper Jul 12 '16 at 22:37
  • $\begingroup$ It's in the first link I gave. $\endgroup$ – sambler Jul 13 '16 at 6:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.