Python "createNode" function

   38483   13   0
User Avatar
Member
15 posts
Joined: 4月 2008
Offline
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!
User Avatar
Member
3 posts
Joined: 7月 2007
Offline
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:
http://www.sergepogosyan.com [sergepogosyan.com]
3dsmax scripts and tips/tricks.
User Avatar
Member
4140 posts
Joined: 7月 2005
Offline
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.
John Coldrick
User Avatar
Member
15 posts
Joined: 4月 2008
Offline
Ok! Thanks!
User Avatar
Member
10 posts
Joined: 1月 2007
Offline
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.
User Avatar
スタッフ
4525 posts
Joined: 7月 2005
Offline
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
User Avatar
Member
10 posts
Joined: 1月 2007
Offline
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!
User Avatar
Member
10 posts
Joined: 1月 2007
Offline
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')
User Avatar
Member
1922 posts
Joined: 11月 2006
Offline
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.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
10 posts
Joined: 1月 2007
Offline
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!
User Avatar
Member
10 posts
Joined: 1月 2007
Offline
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
User Avatar
Member
1922 posts
Joined: 11月 2006
Offline
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))
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
10 posts
Joined: 1月 2007
Offline
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.
User Avatar
Member
15 posts
Joined: 4月 2008
Offline
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!
  • Quick Links