csp Posted April 15, 2015 Share Posted April 15, 2015 In a tool I have a string parameter where the user should type full path to parameter of any node. I want also to give the option to paste copied relative references and convert that expression to string with the full path. The following callback script does all that but it has as a result the red stripes warning on the node. The warning is: Unable to evalulate expression. Why is this happening? How can you avoid this error? If not, is there another way to get the same result? # Fix wedge channels and check if valid def fixchan(parm): p = parm.getReferencedParm() value = parm.evalAsString() if value: if p.path() != parm.path(): parm.setExpression('') # overwrite parm.deleteAllKeyframes() # clear parameter parm.set(p.path()) # set path tp parm else: if not p.node().parm(value): hou.ui.setStatusMessage('This parameter does not exist. Please check the path again or Paste Copied [Relative] Reference.', severity=hou.severityType.Warning) parm.set('') Cheers, Quote Link to comment Share on other sites More sharing options...
csp Posted April 17, 2015 Author Share Posted April 17, 2015 I guess there is no solution to that? I have attached an otl running this code. test.otl Quote Link to comment Share on other sites More sharing options...
Atom Posted April 19, 2015 Share Posted April 19, 2015 (edited) Have you looked at the docs? Evalutes this parameter at the current frame and returns the result as a string. If you want the string contents of the parameter before variable expansion and expression evaluation then call hou.Parm.unexpandedString. Raises hou.TypeError if the value cannot be converted to a string. Try placing the evalAsString inside a TRY/EXCEPT or unexpand the string as the docs suggest. Edited April 19, 2015 by Atom Quote Link to comment Share on other sites More sharing options...
csp Posted April 20, 2015 Author Share Posted April 20, 2015 Replacing value = parm.evalAsString() to value = parm.unexpandedString() will not solve the problem, I tried that. Also its hard to trace the error because when I am running the code line by line from Python Shell, will not error. While writing the reply, I think I fixed it. I just change the order of the lines: parm.deleteAllKeyframes() # clear parameter parm.set(p.path()) # set path tp parm to: parm.set(p.path()) # set path tp parm parm.deleteAllKeyframes() # clear parameter Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.