Python question

   1599   2   1
User Avatar
Member
46 posts
Joined: March 2015
Offline
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\ui.py", line 1035, in decorator
    func, *args, **kwargs
  File "C:/PROGRA~1/SIDEEF~1/HOUDIN~1.390/houdini/python2.7libs\hdefereval.py", line 45, in executeInMainThreadWithResult
    return _queueDeferred(code, args, kwargs, block=True)
  File "C:/PROGRA~1/SIDEEF~1/HOUDIN~1.390/houdini/python2.7libs\hdefereval.py", 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
Member
4549 posts
Joined: Feb. 2012
Offline
Hi,

hou.ui.readInput('name')
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! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
46 posts
Joined: March 2015
Offline
Thanks Yunus,

It worked !!
  • Quick Links