Jump to content

python-creating and selecting nodes


logix1390

Recommended Posts

Hello,

I have some python code that creates two different nodes in the `out` context.

My question is. how can I create multiple nodes in one line instead of two. So far I have this:

mantra=hou.node("/out").createNode("ifd");
hou.node("/out").createNode("geometry")
 

Is there a way I can shorten this line of code so that I can store both nodes that are being created in one variable?

My goal is to basically connect them as they are created. 

Any help would be greatly appreciated. 

thank you.

 

Link to comment
Share on other sites

I don't think so, because there are additional tasks you may want to do as well. Like set flags, overwrite default parameter values, connect inputs and position them in the network etc..

def returnValidHoudiniNodeName(passedItem):
    # Thanks to Graham on OdForce for this function!
    # Replace any illegal characters for node names here.
    return re.sub("[^0-9a-zA-Z\.]+", "_", passedItem)

# Create the Material node.
mat_name = returnValidHoudiniNodeName("mat_%s" % local_name_only)
node_mat = node_geo.createNode("material", mat_name)
if node_mat != None:
	node_mat.parm("shop_materialpath1").set("/shop/%s" % shader_name)
	node_mat.setInput(0,node_uv)
	node_mat.moveToGoodPosition()
	node_mat.setDisplayFlag(1)
	node_mat.setRenderFlag(1)

 

Edited by Atom
Link to comment
Share on other sites

Hi Atom,

Thank you for the response. I am not sure what is going on in the first half of the code.
 

def returnValidHoudiniNodeName(passedItem):
    # Thanks to Graham on OdForce for this function!
    # Replace any illegal characters for node names here.
    return re.sub("[^0-9a-zA-Z\.]+", "_", passedItem)

# Create the Material node.
mat_name = returnValidHoudiniNodeName("mat_%s" % local_name_only)
node_mat = node_geo.createNode("material", mat_name)
if node_mat != None:
	node_mat.parm("shop_materialpath1").set("/shop/%s" % shader_name

 

What exactly is going on here? Thank you again.

 

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...