some Python basic question

   3793   3   1
User Avatar
Member
104 posts
Joined: March 2008
Offline
how do i use the variable in “tx”

ps:
>>> x = 200

in /obj/geo1/tx ; i don't know how to put the x variable in tx.

i try:
hou.ch(x)
hou.ch($x)
hou.ch(“x”)
hou.ch(“$x”)
$x
x
tx = x


can some one tell what command should i use to using Python HOM to input variable please ?
User Avatar
Member
1908 posts
Joined: Nov. 2006
Offline
In your case you are attempting to access a variable declared in the global scope in a parameter. To do this you need to import the main module in your parameter. Putting the following into your will work.

import __main__
return __main__.x

http://www.sidefx.com/docs/houdini10.0/hom/independent [sidefx.com]
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
104 posts
Joined: March 2008
Offline
Thanks for reply but I not really got the point of import

here is the image, am i miss understanding anything ?

Attachments:
python.jpg (48.9 KB)

User Avatar
Member
104 posts
Joined: March 2008
Offline
and the textport return error msg was as follow :

>>> x =200
>>> import __main__
>>> return __main__.x
File “<console>”, line 1
SyntaxError: ‘return’ outside function (<console>, line 1)
>>>
  • Quick Links