quote in quote in expression - Hscript unable to evaluate

   1886   3   0
User Avatar
Member
13 posts
Joined: June 2018
Offline
chf("../../"+`chs("../switch1/name")`+"/RS_objprop_displace_scale")

This is not working "Error: Unable to evaluate expression (Syntax error (/obj/RENDER_GEO/displacement/displacement_scale))."

Could someone guide me with how to write this correctly? I am not very clear about when to use ` or "

note I use a switch to render multiple geometries one after the other, then I want to reference parameters from the selected geometry using the expression above. on my switch I get the name of the selected Geo using
opinput(".",chs("input"))
which correspond to chs("../switch1/name")

Thank you!
Edited by paulfe - Sept. 9, 2023 19:12:40
User Avatar
Member
9374 posts
Joined: July 2007
Offline
try this
ch("../../" + chs("../switch1/name") + "/RS_objprop_displace_scale")
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
13 posts
Joined: June 2018
Offline
Thank you this is working!
User Avatar
Staff
445 posts
Joined: Feb. 2008
Offline
paulfe
I am not very clear about when to use ` or "

Float and Int parameters automatically switch to using an expression if you enter a non-numerical value, it's fairly explicit so you don't need to wrap the expression in backticks.

Strings on the other hand can be a lot more ambiguous. You can either explicitly create an expression (the parm input field will turn green) and type your expression without the backticks, or you can use backticks to insert strings that need to be evaluated as expressions within regular string inputs.

So:

$HIP/render/beauty_`opdigits(".")`.$F4.exr< the parm input field is grey, it uses the value as-is (it does expand variables, i.e: $HIP), and evaluates whatever expression is wrapped in ``

and
"$HIP/render/beauty_"+opdigits(".")+".$F4.exr"
< the parm input field is green, it evaluates the hscript expression.

To create an expression on string parms, one way is to select the input field (click inside it) and hit Ctrl+E. This brings up the expression editor. Enter your expression, select "Hscript Expression" from the dropdown to the left of the Apply button, and hit Apply.
  • Quick Links