Search - User list
Full Version: Python "createNode" function
Root » Houdini Indie and Apprentice » Python "createNode" function
froure
Hi!

I have a problem with python “createNode()” function.

For create a box, for example, I write: “ box = geo.createNode('box')”. But I don't have a list of parameters for create another nodes (Extrude, Lsystem, tube…..).

Does some list of parameters exist for this function? In the tutorials it is not exist.

Thank you very much!
chico
List of parameters can be accessed via parms() method of the node - box.parms()
You can create another node, ‘extrude’ for example, just like the first node - with createNode method and then connect your box node to extrude node via setInput method called from the second node, that is clear, since you're specifying input.

This info is from hom documentation :wink:
JColdrick
I don't think that's what he's asking for. He was interested in a method that lists all possible node types that he could enter. AFAIK, the only thing you can currently use is ‘opadd’ - but that's sorta cheating since it's not python, it's hscript.

Hopefully these sorts of corners get filled in as time goes on…

Cheers,

J.C.
froure
Ok! Thanks!
Array
JColdrick
I don't think that's what he's asking for. He was interested in a method that lists all possible node types that he could enter. AFAIK, the only thing you can currently use is ‘opadd’ - but that's sorta cheating since it's not python, it's hscript.

Hopefully these sorts of corners get filled in as time goes on…

Cheers,

J.C.

Is there a list somewhere which actually lists all of the possible node types that can be passed into createNode()? I've been trying to figure it out all morning and its driving me nuts.
mtucker
This:
hou.nodeTypeCategories().nodeTypes()
will return a dictionary mapping the node type names (which can be passed to createNode) to hou.NodeTypes. Obviously replace “Sop” with the node type category you are interested in.

Mark
Array
mtucker
This:
hou.nodeTypeCategories().nodeTypes()
will return a dictionary mapping the node type names (which can be passed to createNode) to hou.NodeTypes. Obviously replace “Sop” with the node type category you are interested in.

Mark

Ooof, difficult to read the output, but ultimately useful. Thanks!
Array
Hmmm…OK I have my list now, but I am still unsure of how to make a grid or sphere object using createNode()…is there some other argument which gets passed in along with ‘geo’? I.e. my current usage is:

someObject = hou.node('/obj').createNode('geo')
graham
A grid or a sphere cannot be made at the object level. You have to create a geo object, then create the grid of sphere inside it. What you are trying to do is actually the result of a tool operation that creates a geo object, destroys the file sop, then creates the required type of sop.
Array
graham
A grid or a sphere cannot be made at the object level. You have to create a geo object, then create the grid of sphere inside it. What you are trying to do is actually the result of a tool operation that creates a geo object, destroys the file sop, then creates the required type of sop.

Ahhh, gotcha, thanks!
Array
OK, here are my first baby steps into Houdini:



#===========================================
# make a group of spheres
#===========================================

hou.hipFile.clear()

def createSpheres(numSpheres, dX, mY, mZ):

i = 0

temp = 0

spheres = * numSpheres

for i in range(0, numSpheres):

tString = “sphere_” + str(i)

spheres = hou.node('/obj').createNode('geo', tString, 0 )
spheres.node('/obj/' + tString).createNode('sphere')

spheres.moveToGoodPosition()

spheres.parm('tx').set(i * dX)
temp = spheres.evalParm('tx') % mY
spheres.parm('ty').set(temp)
temp = spheres.evalParm('ty') % mZ
spheres.parm('tz').set(temp)


createSpheres(100, 2, 5, 8)



This is a lot of fun! Thanks again for the help
graham
Here's that written in a more Python/Houdini way since it doesn't require
all the extra assignments and list usage and taking advantage or some of the nice Houdini features.


def createSpheres(numspheres, tx, ty, tz):

spheres =

for i in range(numspheres):
geo = hou.node('/obj').createNode('geo','sphere_' + str(i))
geo.node('file1').destroy()
geo.createNode('sphere')
geo.moveToGoodPosition()

spheres.append(geo)

xval = i * tx
yval = xval % ty
zval = yval % tz
geo.parmTuple('t').set((xval, yval, zval))
Array
graham
Here's that written in a more Python/Houdini way since it doesn't require
all the extra assignments and list usage and taking advantage or some of the nice Houdini features.


def createSpheres(numspheres, tx, ty, tz):

spheres =

for i in range(numspheres):
geo = hou.node('/obj').createNode('geo','sphere_' + str(i))
geo.node('file1').destroy()
geo.createNode('sphere')
geo.moveToGoodPosition()

spheres.append(geo)

xval = i * tx
yval = xval % ty
zval = yval % tz
geo.parmTuple('t').set((xval, yval, zval))

Oh, awesome, thanks! I should also mention that this is not only my first foray into Houdini, but also Python. ops:

At work I use nothing but C, and not even ANSI 99 C. It's like a time warp, haha.
froure
Hi friends!

I create a little functions for view a parameters of nodes:


def api(node):
g = hou.node('/obj').createNode('geo')
n = g.createNode(node)
print n.parms()
g.destroy()

def api2(node, param):
g = hou.node('/obj').createNode('geo')
n = g.createNode(node)
print n.parm(param).parmTemplate()
g.destroy()


in python shell:


import myfilefuntions
myfilefunctions.api('')
myfilefunctions.api2('', '')


It is somethings stupid, but for working is good! XD

Thanks!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB