Hi there,
This might be an easy one for you all, but I can't get the arg and argc functions to work properly in VEX on my attribute wrangle.
The Houdini doc says that something like argc("Syntax Examples Please") should return a value of 3 but I can't get it working.
//I would expect to get an integer with a value of 3 out of this one:
i@count = `argc("Syntax Examples Please");
//I would expect to get a string "Examples" out of this one:
s@select = `arg("Syntax Examples Please", 1);
What's the right syntax for the arg and argc functions?
I'm currently using Houdini 18.5
Thanks.
What's the right syntax for the arg and argc functions?
1899 4 0-
- allkidsintheend
- Member
- 3 posts
- Joined: Sept. 2021
- Offline
-
- animatrix_
- Member
- 5100 posts
- Joined: Feb. 2012
- Offline
Hi,
If you want to use hscript expressions in VEX, use them in parameters and then reference that parameter in VEX:
1. Create an integer parameter
2. Set its expression to:
3. Use this in VEX:
If you want to use hscript expressions in VEX, use them in parameters and then reference that parameter in VEX:
1. Create an integer parameter
2. Set its expression to:
argc("Syntax Examples Please")
3. Use this in VEX:
i@count = chi("myintparm");
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
-
- allkidsintheend
- Member
- 3 posts
- Joined: Sept. 2021
- Offline
Thanks animatrix_
works perfectly for both functions.
I tried applying the same logic to the arg function and at first I didn't quite get the result I was hoping for.
1. I created a string parameter
arg("Syntax Examples Please", 1)
2. I used this in VEX
s@select = chs("mystringparm");
At first it would just return the whole formula (arg("Syntax Examples Please", 1)) as written in my string parameter.
To get the right result, I had to put a "`" character in front of my arg function, so this:
`arg("Syntax Examples Please", 1)
works just fine.
Thanks a lot.
works perfectly for both functions.
I tried applying the same logic to the arg function and at first I didn't quite get the result I was hoping for.
1. I created a string parameter
arg("Syntax Examples Please", 1)
2. I used this in VEX
s@select = chs("mystringparm");
At first it would just return the whole formula (arg("Syntax Examples Please", 1)) as written in my string parameter.
To get the right result, I had to put a "`" character in front of my arg function, so this:
`arg("Syntax Examples Please", 1)
works just fine.
Thanks a lot.
-
- animatrix_
- Member
- 5100 posts
- Joined: Feb. 2012
- Offline
Oh yes to evaluate hscript expressions inside string parameters, you have to use `s. That's normal because the result is a string which can only be shown properly in a string parameter.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
-
- tamte
- Member
- 9384 posts
- Joined: July 2007
- Offline
allkidsintheendnot just in front, it has to be in front and back as it's creates a scope for expression within the string
To get the right result, I had to put a "`" character in front of my arg function, so this:
`arg("Syntax Examples Please", 1)
so this should work
i@count = `argc("Syntax Examples Please")`; s@select = "`arg('Syntax Examples Please', 1)`";
so if you inject it like this it would just resolve the value before as a constant, so you wouldn't be able to provide phrase or index from vex variables or even animate it
so you either do it as animatrix suggested with spare parameter, which will allow it to be animated and referenced, but still not passed from VEX
or for pure VEX you can use split function
string phrase = "Syntax Examples Please"; string words[] = split(phrase); i@count = len(words); s@select = words[1];
Edited by tamte - Jan. 26, 2023 13:18:29
Tomas Slancik
CG Supervisor
Framestore, NY
CG Supervisor
Framestore, NY
-
- Quick Links

