global vex include

   9550   8   3
User Avatar
Member
22 posts
Joined: June 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]
User Avatar
Member
459 posts
Joined: Oct. 2011
Offline
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
http://www.racecar.no [www.racecar.no]
User Avatar
Member
22 posts
Joined: June 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]
User Avatar
Member
459 posts
Joined: Oct. 2011
Offline
mrWolf
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.
It 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]
EDIT: Not that i know how to do that

-b
http://www.racecar.no [www.racecar.no]
User Avatar
Member
22 posts
Joined: June 2006
Offline
bonsak
mrWolf
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.
It 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]
EDIT: Not that i know how to do that

-b
Yeah,
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]
User Avatar
Member
459 posts
Joined: Oct. 2011
Offline
mrWolf
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.
Hehe. As simple as that

-b
http://www.racecar.no [www.racecar.no]
User Avatar
Member
96 posts
Joined: May 2008
Offline
It'd be awesome if we had access to the hou.session module from within VEX and if we could store data in there as well. That'd solve so many problems…
User Avatar
Member
20 posts
Joined: Sept. 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 - July 23, 2021 16:38:34
User Avatar
Member
1 posts
Joined: Jan. 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);
```
  • Quick Links