HExpression Error ?

   2954   11   1
User Avatar
Member
766 posts
Joined: April 2014
Offline
I suppose I can't use this expression on a containers Y translate;
if($F>12)then chkey -f 15 else chkey -f 5 endif
which gives me an error ? As well I can't use it because the if clauses must be on seperate lines ?
【T】【C】【S】
User Avatar
Member
2537 posts
Joined: June 2008
Offline
You can use multiple line expressions in Houdini. Click in the field where you type the expression and press CTRL-E/CMD-E to activate the multi-line editor. You also get a syntax warning log in the lower areas as well.

You may want to look up the syntax for IF, I don't think then is part of it in this Script language.

More C like…
if($F>12 0:1)
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
766 posts
Joined: April 2014
Offline
Open Textport and do a help for if, you'll see the example does place the word ‘then’

I keep getting the error extra tokens detected

if($F>12 0:1) chkey -f 15 chkey -f 5
if($F>12 0:1) ? (chkey -f 15)(chkey -f 5)

Does it matter if I give a value for the frame; if it does, this is what I've attempted although I can't figure out my syntax errors ?

if($F>12 0:1) (chkey -f 15 -v 8 -F ‘bezier()’)(chkey -f 5 -v 7 ‘bezier()’)
Edited by _Christopher_ - June 27, 2016 10:24:44
【T】【C】【S】
User Avatar
Member
2537 posts
Joined: June 2008
Offline
Ok, after looking up the Hscript IF syntax it looks like you need commas, not space colon.
if($F>12,15,5)
So you don't really need to set a chkey at all, The result will become the value at that time. The first value is if the statement is True and the second value is if the statement is False.

Place the above code in the Y-Translate field to achieve your original request.
Edited by Enivob - June 27, 2016 11:48:12
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
766 posts
Joined: April 2014
Offline
Thanks the expression worked, I can't see my, in this case, sphere ?
【T】【C】【S】
User Avatar
Member
2537 posts
Joined: June 2008
Offline
Same thing happened to me. Zoom out. The Y position of 15 units is fairly far up.
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
766 posts
Joined: April 2014
Offline
Why don't I have to use chkey ?

The expression only adds a keyframe at frame 15, I don't quite understand what the other arguments are for ?
Edited by _Christopher_ - June 27, 2016 23:10:04
【T】【C】【S】
User Avatar
Member
2537 posts
Joined: June 2008
Offline
The expression does not add a keyframe. It takes the place of the keyframe and returns a value for the channel instead. You can't effectively have both on the same field. This means you either keyframe the field or you program the field. The expression programs the field and returns a result.

The two trailing values are the result for the True/False case of the If statement.
For instance we can re-write the expression so the result only moves up and down for the first 24 frames then jumps to a final location of 2.
if(($F<24),(sin($F)*10),2)
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
766 posts
Joined: April 2014
Offline
Interesting
How would creating a keyframe work ?
chkey -f 18 -v 15
Edited by _Christopher_ - June 28, 2016 20:02:18
【T】【C】【S】
User Avatar
Member
2537 posts
Joined: June 2008
Offline
Move the timeline to frame #18, type in 15 for the Y value then ALT-CLICK on the field to create a keyframe with the current value (it turns green). Then Middle-CLICK on the field to bring up the curve editor where you can manipulate the keyframes.
Edited by Enivob - June 29, 2016 11:16:35
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
766 posts
Joined: April 2014
Offline
I meant with the expression chkey; as the sample code I posted ?
【T】【C】【S】
User Avatar
Member
766 posts
Joined: April 2014
Offline
I must use chadd before I can use chkey. I added a bezier() curve by using chadd to the Tx; but how do I use chkey ?
Edited by _Christopher_ - July 3, 2016 01:27:20
【T】【C】【S】
  • Quick Links