[Sidefx-houdini-list] problem using hom setExpression from callback script

François Duchesneau sidefx at trinix.ca
Sun Sep 11 02:58:32 EDT 2011


Just throwing ideas here. Do you mean when you type

ifs(strcmp('foo','foo')==0,'true','false')

directly in your parameter it works?

Also when you say that when you use

hou.node("/obj/null1").parm("parm").setExpression("if(strcmp('foo','foo')==0,1,2)",
hou.exprLanguage.Hscript)

it works, are you setting this expression in the same parameter as the 
ifs version that doesn't work? If yes, then it makes sense you've got an 
error if you're trying to set a string inside a float parameter for example.

Also, make sure that when you set the expression via Python your 
parameter is actually evaluating a Python expression and not an Hscript.

Hope this help.

François

François

Daniel Flood wrote:
> Hey folks,
>
> I'm setting an expression via hou.node().parm().setExpression(), and I have
> a problem where the parameter expression evaluates correctly, however when
> triggered from a callback script (either code in a shelf button, or a parm
> gui callback script), I the node goes red and shows the following error:
> "Channel Evaluation Error Bad data type for function or operation"
>
> here's my callback:
>
> hou.node("/obj/null1").parm("parm").setExpression("ifs(strcmp('foo','foo')==0,'true','false')",
> hou.exprLanguage.Hscript)
>
> This expression evaluates error free if ran from the hython shell, however
> if called back from a shelf button, if throws up a red node / MMB click
> error (note that the parm is actually being evaluated correctly).  I did
> notice that the following expression when set by the same method evaluates
> without any error:
>
> hou.node("/obj/null1").parm("parm").setExpression("if(strcmp('foo','foo')==0,1,2)",
> hou.exprLanguage.Hscript)
>
> So it seems I am not doing a good job of declaring my data types as it seems
> happy with integers and not strings. Could this be because strcmp returns an
> integer, I'm mixing up data types? If so any suggestions for how I should do
> it? Could this be some python parsing error, as the injected hscript
> expression does evaluate correctly?
>
> So I'm at my wit's end on this...any ideas would be greatly appreciated!
> even the example on the sidefx docs seem to show mixing data types in an
> "ifs" statement: http://www.sidefx.co...expressions/ifs
>
> cheers,
> Dan
> _______________________________________________
> Sidefx-houdini-list mailing list
> Sidefx-houdini-list at sidefx.com
> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
>
>   



More information about the Sidefx-houdini-list mailing list