Python question

   1641   2   1
User Avatar
46 posts
Joined: March 2015
Hey There,
Can somebody explain please why this code works fine:
hou.node("/obj/").createNode('geo', 'test')

But this does not?
name = hou.ui.readInput('name')
hou.node("/obj/").createNode('geo', name)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "C:/PROGRA~1/SIDEEF~1/HOUDIN~1.390/houdini/python2.7libs\houpythonportion\", line 1035, in decorator
    func, *args, **kwargs
  File "C:/PROGRA~1/SIDEEF~1/HOUDIN~1.390/houdini/python2.7libs\", line 45, in executeInMainThreadWithResult
    return _queueDeferred(code, args, kwargs, block=True)
  File "C:/PROGRA~1/SIDEEF~1/HOUDIN~1.390/houdini/python2.7libs\", line 104, in _queueDeferred
    raise exc_info[1]
TypeError: in method 'Node_createNode', argument 3 of type 'char const *'

Basically it generates error if i let user set custom name for the node via readInput() method.
The problem is probably simple but i can’t sort why...

Thanks for any help!
Edited by mikhail s - Dec. 29, 2020 00:27:52
User Avatar
4594 posts
Joined: Feb. 2012

returns a tuple where the string is the second element. So you should use:

hou.node("/obj/").createNode('geo', name[1])
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [] | |
User Avatar
46 posts
Joined: March 2015
Thanks Yunus,

It worked !!
  • Quick Links