global vex include
10689 9 4- mrWolf
- Member
- 22 posts
- Joined: 6月 2006
- Offline
I am wondering if there is any way to #include a .vfl vex file so that the functions sourced in the file are available in the whole Houdini session. More specifically, in every Wrangle Node. I was expecting to find directions about this in the section “user-defined functions”, in the VEX Language reference in the houdini help, with no luck !
Alessandro Pepe
http://www.alessandropepe.com [www.alessandropepe.com]
http://pepefx.blogspot.com [pepefx.blogspot.com]
http://www.alessandropepe.com [www.alessandropepe.com]
http://pepefx.blogspot.com [pepefx.blogspot.com]
- bonsak
- Member
- 459 posts
- Joined: 10月 2011
- Offline
- mrWolf
- Member
- 22 posts
- Joined: 6月 2006
- Offline
bonsak
Hi
Not sure if this is exactly what your'e after but if you put your vfl's anywhere in the $HOUDINI_VEX_PATH or in $HOME/vex/include. Then you can include them in your wranglers:
#include <my_external_vex.vfl>
-b
That's handy, thank you Bonsak.
But I was looking for a way to avoid writing the include statement itself in every Wrangle node. Basically an “include” that works at the session level, instead of the node level. I've already asked this question around and never got an answer. I guess it's not possible.
Alessandro Pepe
http://www.alessandropepe.com [www.alessandropepe.com]
http://pepefx.blogspot.com [pepefx.blogspot.com]
http://www.alessandropepe.com [www.alessandropepe.com]
http://pepefx.blogspot.com [pepefx.blogspot.com]
- bonsak
- Member
- 459 posts
- Joined: 10月 2011
- Offline
mrWolfIt would be great if that was possible. Maybe you have to make your own plugin (hdk) for this to work though. http://www.sidefx.com/docs/hdk14.0/_h_d_k__vex_op.html [sidefx.com]
Basically an “include” that works at the session level, instead of the node level. I've already asked this question around and never got an answer. I guess it's not possible.
EDIT: Not that i know how to do that
-b
- mrWolf
- Member
- 22 posts
- Joined: 6月 2006
- Offline
bonsakYeah,mrWolfIt would be great if that was possible. Maybe you have to make your own plugin (hdk) for this to work though. http://www.sidefx.com/docs/hdk14.0/_h_d_k__vex_op.html [sidefx.com]
Basically an “include” that works at the session level, instead of the node level. I've already asked this question around and never got an answer. I guess it's not possible.
EDIT: Not that i know how to do that
-b
OR
A workaround that just came to my mind is simply to save a default preset for the wrangle nodes that always contains an #include line pointing to a certain .vfl file containing, for instance, general purpose functions.
Not ideal, but it should do the job.
Alessandro Pepe
http://www.alessandropepe.com [www.alessandropepe.com]
http://pepefx.blogspot.com [pepefx.blogspot.com]
http://www.alessandropepe.com [www.alessandropepe.com]
http://pepefx.blogspot.com [pepefx.blogspot.com]
- bonsak
- Member
- 459 posts
- Joined: 10月 2011
- Offline
- ripclaw
- Member
- 96 posts
- Joined: 5月 2008
- Offline
- kif11
- Member
- 20 posts
- Joined: 9月 2012
- Offline
I just learned from this [www.youtube.com] wonderful video that you can do this
#include "$HIP/include/mylib.vfl" say_hello();
Edited by kif11 - 2021年7月23日 16:38:34
- hroberts
- Member
- 1 posts
- Joined: 1月 2024
- Offline
I'm very late, but one approach I saw in LABS nodes is using `chs("../code_string")` in VEX. This causes VEX to evaluate the string as if it was actual VEX code in the wrangle. For example, add this to a detail wrangle:
```
vector addToPos(vector p) {
return p + {1, 2, 3};
}
```
Then in any other wrangle you can run that code with chs():
```
// Append the code string and run it (like #include)
`chs("../your_wrangle/snippet")`
v@P = addToPos(v@P);
```
```
vector addToPos(vector p) {
return p + {1, 2, 3};
}
```
Then in any other wrangle you can run that code with chs():
```
// Append the code string and run it (like #include)
`chs("../your_wrangle/snippet")`
v@P = addToPos(v@P);
```
- UtilitasArts
- Member
- 16 posts
- Joined: 4月 2021
- Offline
hroberts
What!!
This is crazy!!
This is so much more usefull to me. Because it works so dynamically and keeps long vex code much much cleaner.
Thanks a bunch for sharing!
hroberts
I'm very late, but one approach I saw in LABS nodes is using `chs("../code_string")` in VEX. This causes VEX to evaluate the string as if it was actual VEX code in the wrangle. For example, add this to a detail wrangle:
```
vector addToPos(vector p) {
return p + {1, 2, 3};
}
```
Then in any other wrangle you can run that code with chs():
```
// Append the code string and run it (like #include)
`chs("../your_wrangle/snippet")`
v@P = addToPos(v@P);
```
What!!
This is crazy!!
This is so much more usefull to me. Because it works so dynamically and keeps long vex code much much cleaner.
Thanks a bunch for sharing!
-
- Quick Links