hscriptFloatExpression(expression)
→ float
This function will force the return type to be a float.
Most of the time, you want to use hou.hscriptExpression() over this function. See it for more examples.
Raises hou.OperationFailed if the expression is invalid or generates an error occur during evaluation.
If the expression contains variables, Houdini will attempt to evaluate them as floats, and use the value 0.0 if they cannot be converted to floats. However, if the expression definitely evaluates to a string that does not start with a number, this function raises hou.OperationFailed.
>>> hou.hscriptFloatExpression("3") 3.0 >>> hou.hscriptFloatExpression("'3'") 3.0 >>> hou.hscriptFloatExpression("'3X'") 3.0 >>> hou.hscriptFloatExpression("'X3'") Traceback (most recent call last): File "<console>", line 1, in <module> File "/opt/hfs10.5/houdini/python2.5libs/hou.py", line 9359, in hscriptFloatExpression return _hou.hscriptFloatExpression(*args) OperationFailed: The attempted operation failed. Bad data type for function or operation >>> hou.hscriptFloatExpression("3X") Traceback (most recent call last): File "<console>", line 1, in <module> File "/opt/hfs10.5/houdini/python2.5libs/hou.py", line 9359, in hscriptFloatExpression return _hou.hscriptFloatExpression(*args) OperationFailed: The attempted operation failed. Syntax error - extra tokens detected in expression >>> hou.hscriptFloatExpression("$F") 1.0 >>> hou.hscriptFloatExpression('"$F"') 1.0 >>> hou.hscriptFloatExpression("$HOME") 0.0 >>> hou.hscriptFloatExpression('"$HOME"') Traceback (most recent call last): File "<console>", line 1, in <module> File "/opt/hfs10.5/houdini/python2.5libs/hou.py", line 9359, in hscriptFloatExpression return _hou.hscriptFloatExpression(*args) OperationFailed: The attempted operation failed. Bad data type for function or operation >>> hou.hscriptFloatExpression("'$F'") Traceback (most recent call last): File "<console>", line 1, in <module> File "/opt/hfs10.5/houdini/python2.5libs/hou.py", line 9359, in hscriptFloatExpression return _hou.hscriptFloatExpression(*args) OperationFailed: The attempted operation failed. Bad data type for function or operation
See also |