I'm hoping someone can help. I want to create a scatter node which is the child of the parent node although it won't have a connection to the parent node but is the child of variable theNode ?
I also want to set some parameters for the variable theNode ?
Neither of the two is working without an error.
forninhou.selectedNodes():print("the list is"+n.name())theNode=hou.node('/obj/sphere/sphere2')print(theNode.path())theNode.setName("theSphere")ColorNode=hou.Color(1,0.8,1.7)theNode.setColor(ColorNode)theNode.createNode("scatter1","theScatter")theNode("scatter1").children()theNode.setParms({"radx":2.2,"radz":1.2})iftheNode.name():print("the node is selected")else:print("couldn't make the node selected")
I'm not sure what you are after, but there are some basic problems with the code you have as entered. the createNode() function takes a node type name as an argument, and the rest as keyword arguments. There is no such type as “scatter1” unless you have defined such a type yourself. ‘theNode’ is an instance of a hou.SopNode object (“theSphere” if it exists), and cannot be called as a function, so calling .children() does not make sense here either.
Perhaps something like this is what you are after:
theNode=hou.node("/obj/sphere/sphere2")iftheNode:print("the node is selected")theNode.setName("theSphere")ColorNode=hou.Color(1,0.8,1.7)theNode.setColor(ColorNode)theParent=theNode.parent()theScatter=theParent.createNode("scatter",node_name="theScatter")theNode.setParms({"radx":2.2,"radz":1.2})else:print("couldn't make the node selected")