Can't evaluate hou.pwd(): unknown function in expression

   1887   4   0
User Avatar
Member
692 posts
Joined: Aug. 2019
Offline
I have this simple Attribute Create:



It causes an error: "Unknown function in expression". But why? `hou.pwd().path()` is definitely a valid function:




Why does the exact same logic work for integer attribute, but doesn't string attribute?
Edited by raincole - Dec. 30, 2021 16:07:50

Attachments:
Screenshot 2021-12-31 050336.png (129.7 KB)
Screenshot 2021-12-31 050502.png (60.1 KB)

User Avatar
Member
9376 posts
Joined: July 2007
Offline
you can't use ticks to evaluate Python expression inside a string
you have to make sure to purely insert an expression that generates your full string

- so make sure your parameter is toggled to expression (LMB click on label until its highlighted)
and then
- either Alt+LMB to insert a keyframe and type in your expression
or
- Alt+E to open floating Editor (should be in Edit Expression mode instead of Edit String) type in your expression and apply and that will create the keyframe also
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
692 posts
Joined: Aug. 2019
Offline
tamte
you can't use ticks to evaluate Python expression inside a string
you have to make sure to purely insert an expression that generates your full string

- so make sure your parameter is toggled to expression (LMB click on label until its highlighted)
and then
- either Alt+LMB to insert a keyframe and type in your expression
or
- Alt+E to open floating Editor (should be in Edit Expression mode instead of Edit String) type in your expression and apply and that will create the keyframe also

Many thanks! So backticks are only for HScript?
User Avatar
Member
9376 posts
Joined: July 2007
Offline
raincole
Many thanks! So backticks are only for HScript?
yes, since string parameters dont have any scripting language associated to them until you set a keyframe, so houdini wouldn't be able to know which language you are using
and the node default language is just default

if you really want to insert python generated string into string parameter using ticks to avoid generating the whole string in Python you can use pythonexprs() Hscript function
`pythonexprs("hou.pwd().path()")`
which of course is unnecessary for your case but may be handy in some cases
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
8177 posts
Joined: Sept. 2011
Offline
Don't use python for that

`opfullpath(".")`
is the equivalent hscript
  • Quick Links