Jump to content

Connecting nodes to different inputs by Python Lang


Bart87

Recommended Posts

Hi,

I am trying to do my asset for houdini and I am looking a method which can allow me to connect one node to anoter

I use something like this, but this option is connecting everything to imput1 ('grey imput')

    staticsolver = doptoolutils.createSolver("staticsolver", True) - create staticsolver node
    staticobject = dopnet.createNode("staticobject") - create staticobject node
    doptoolutils.addObjectToSolver(staticobject, staticsolver, True) - connect staticobject to staticsolver

but some nodes has more inputs:

multisolver has 2 inputs one is grey and another purple - how I can connect my node to the purple one using python language?

and another constraintnetwork has 3 inputs, one grey, green and purple

and also if merge node has 3 inputs connected, how I can tell which should be first?

I need explanation how I can connect something to each input. I found something like this but I dont understand what I should write to make it works:
http://www.sidefx.com/docs/houdini/hom/hou/NodeConnection.html#outputNode

if someone can write to me an example how should I write my script lines which show how I should connect node to purple input in multisolver, how to connect to green and purple input for constraintnetwork and how to define which is the first input in merge node.

I attached picture as example what I want to connect to.

Thank you
Bart

nodes.png

Link to comment
Share on other sites

Check out the help docs on setInput() function. You need two variables, the node to connect and the node to connect to.

The value of 0 is the zero based input to connect to.

node_source.setInput(0,node_target)
node_source.setDisplayFlag(True)
node_target.moveToGoodPosition()

 

Edited by Atom
Link to comment
Share on other sites

15 minutes ago, Atom said:

Check out the help docs on setInput() function. You need two variables, the node to connect and the node to connect to.

The value of 0 is the zero based input to connect to.


node_source.setInput(0,node_target)
node_source.setDisplayFlag(True)
node_target.moveToGoodPosition()

 

I have done something like this, but doesnt work

staticsolver = dopnet.createNode("staticsolver")
staticobject = dopnet.createNode("staticobject")
    
staticobject.setInput(0,staticsolver)
staticobject.setDisplayFlag(True)
staticsolver.moveToGoodPosition()

 

1.png

Edited by Bart87
screenshot
Link to comment
Share on other sites

1 hour ago, Atom said:

Wouldn't it be the other way around?

Did you try...


staticsolver.setInput(0,staticobject)

 

Hay, I found the mistake

there should be

staticsolver.setInput(0,staticobject,0)

1st zero is for input to my staticsolver and 2nd zero is for my staticobject output.
so you only missed one zero but its help me a lot to understand what to do... 

Thank you!!!

Edited by Bart87
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...