Expression in Font Text field... How to??

   4551   0   1
User Avatar
Member
71 posts
Joined: Oct. 2007
Offline
Hello guys,


Although not so newbie with Houdini I still sometimes bump into something harder than usual to understand in the Houdini way of use.
I must admit this one put me into despair…
Once again, a few tips from you would be greatly appreciated

So what I would like to do is quite simple:
- There is a camera camA in my scene, connected, or not, to a SubNet
- I have a Font, nearby on the screenshot but on another network in my real case
- I would like to put an expression in the Font Text field so that if the camera camA is connected to a SubNet its name is displayed, if not something else is displayed.

The thing is, whether I use Expression, HScript or Python, I don't manage to get a code accepting the condition (and I spent quite a lot of time on it). I would then be delighted if you could provide me an answer for each langage so that I get a better understanding of them.

So here is what I did:

Expression:
I expected that line to work in the Text field:
`if('subnet'==optype(opoutputpath(“/obj/camA/”,0)),“1”,“0”)`
… but the node says: Bad data for function or operation (text). It doesn't work either with ifs

An expression such as
`1 + 1` works correctly and the Font displays “2”.
An expression such as
`ifs(1==2,1,0)` works correctly and the Font displays “0”.
An expression such as
`optype(opoutputpath(“/obj/camA/”,0))` works correctly and the Font displays “subnet”.
Any expression such as
`ifs('subnet'==optype(opoutputpath(“/obj/camA/”,0)),1,0)` doesn't work, whatever quotes I put around subnet…


HScript:

I expected that block to work in the Text field:
`if ('subnet'==optype(opoutputpath(“/obj/camA/”,0)) then
“1”
else
“0”
endif`
… but the Expression editor says: Syntax error - extra tokens detected in expression (text)

Anyway such an example doesn't even work, although it seems to be Hscript code:
`if (1==2) then
“1”
else
“0”
endif`

In the Hscript Textport the code works:
/ -> set toto = `(optype(opoutputpath(“/obj/camA/”,0)))`
/ -> echo $toto
subnet

So does this one:
if (1==2) then
echo 1
else
echo 0
endif


Python:

Python seems to be the recommanded langage to use nowadays in Houdini. It is a bit heavier than Hscript for quick expression though.
Nevertheless, here are my tries here:

Fisrt of course I set the Font node to Python (in fact I even started froma new one).
I expected such block to work:
if ('subnet' == (((hou.node('/obj/camA/').outputs())).type()).name()):
1
else:
0
…but the whole block is displayed and not interpreted

This block is also completely displayed:
if (1==2):
“1”
else:
“0”

In the Python shell we have:
'subnet' == (((hou.node('/obj/camA/').outputs())).type()).name()
works and return True

and
if (1==2):
1
else:
0
works and return 0

I guess some basic understanding of the way these language work in Houdini would be needed, but honestly the documentation is not clear at all and i didn't manage to get a clearer overview than the one I have now with it.


Thanks again for any tips, guides or solutions…

werwack
Video Game Graphics TD
  • Quick Links