Pete L

peteski

About Me

Expertise
Indie Gamedev
Location
Australia

Connect

Recent Forum Posts

Add new node under the current selection through python. Nov. 25, 2020, 2:02 a.m.

Wow, that’s amazing!

It’s lot trickier than I thought it would be.
My code will actually unwire random things if used with a merge underneath so it’s kinda bad.

Thank you so much for that!

Add new node under the current selection through python. Nov. 24, 2020, 6:09 p.m.

Hi there,

Is there an easy way to do this through python? I just want to create a new node and attach it under the current.

I have a script that creates the node fine but it seems like a huge pain to wire that new node up. Especially in situations like this.
Everything I'm doing seems really tacky, just kinda hoping I was missing an easy option.

selectedNode = hou.selectedNodes()[0]
parentNode = selectedNode.parent()
newNode = parentNode.createNode("SomeNode")
newNode.setInput(0,selectedNode,0)
newNode.moveToGoodPosition()

#This part breaks things :(
if len(selectedNode.outputs()) > 0:
    outNode = selectedNode.outputs()[0]
    outNode.setInput(0,newNode,0)
    
newNode.setSelected(1,True,False)
newNode.setDisplayFlag(True)

Thanks,
Pete

Crashes when using in screen handles. OSX Nov. 21, 2020, 12:22 p.m.

I’m seeing this in 18.5 but it had been happening in 18 also.