Jump to content

Novice> Python connect shader to suboutput problem


kajjin

Recommended Posts

Hello everyone, im fairly new to houdini so, i might be doing something completely wrong.
At the moment stuck at trying to connect 2 nodes through python.  Im trying to replace a material with a new one that i create through python.

(Original network Image A), the way i do it manually is I just create a MantraShader and drag the output into the suboutput input(Image B), and that works. So, im trying to do the same thing through python. Here is what ive got so far:

import hou
shaderPath = hou.node("/obj/materials/CarPaint/")
OldShader= hou.node("/obj/materials/CarPaint/CarPaint_surface")
shaderConnection= hou.node("/obj/materials/CarPaint/suboutput")
NewShader = shaderPath.createNode('mantrasurface')
NewShader.setName("NewShader")

shaderConnection.setInput(1,NewShader)

The problem is that im not sure if the setInput is the right way to go,

and, i dont fully understand shaders, but  when i disconnect the Oldshader from the suboutput, the input turns from pinkish to white, and when I try to connect my new MantraShader, it doesnt work. (Image C)

Sooo, im definitely doing something wrong xD.

If any of you have an idea of what im doing wrong, or a completely new approach let me know!

 

Cheers!

A.PNG

B.PNG

C.PNG

Link to comment
Share on other sites

setInput is the way to go. You are just confusing surface with material. They are not the same thing, that is why they have different color node connectors. Try to create your new node as a surface type, not a material type.

This GIF shows how you can easily find out the type of a node so you can use that identifier for node creation.

mat.gif

Edited by Atom
  • Like 1
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...