babbel Posted November 1, 2017 Share Posted November 1, 2017 Hello everyone, I get this expression error but I can't figure why. Can someone please tell what i'm doing wrong ? Or maybe it's not possible to do that in this field ? if(ch("../depth")<5){ch("../depth")*4)+1}else{ch("../depth")*3)+1} Thank you, Baptiste Quote Link to comment Share on other sites More sharing options...
babbel Posted November 1, 2017 Author Share Posted November 1, 2017 I found the solution, it's because Houdini's expression has a kind of strange -if syntax-. "if (condition, then, else)" Quote Link to comment Share on other sites More sharing options...
f1480187 Posted November 1, 2017 Share Posted November 1, 2017 There is parentheses mismatch in the original expression, which will break any code. If you want to use classic C-like if (cond) {statement} else {statement}, you need to open full editor via RMB menu and use multi-line expression (it is like a function body without function declaration itself): { if (ch("../depth") < 5) { return ch("../depth") * 4 + 1; } else { return ch("../depth") * 3 + 1; } } What you used is if() expression function. I think it just wraps code above into something that is easier to use inside expressions. Although it evaluates both branches, I doubt if anyone ever had problems with it in practice. 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.