Jump to content
Sign in to follow this  

Custom VEX function input type

Recommended Posts

Hi there,


I'm trying to wrap my head around custom vex functions, mainly from a theoretical point at this stage so not really addressing a specific use, just general knowledge.

When I create a VEX function I believe that I have to specify exactly what type of data it is expecting from the arguments and exactly what type of data it will return.



function int my_function(float a){

	return int(a);


in which case I have to feed it an INT argument and it will always return an INT value.


My question is this, is there any way of creating a VEX function which can accept multiple arguments, but not fail if one or more of those arguments are absent when the function is called? Or better yet a way of taking a single argument with out specifying what type of data that argument should be?

I'm guessing that this is somehow possible as most of the existing Houdini VEX functions work with multiple flavours of input.

Thanks in advance.



Share this post

Link to post
Share on other sites

it's called function overloading. for details see http://www.sidefx.com/docs/houdini/vex/lang.html#functions

this is a quick basic example where VEX determines which function to use based on the argument types you feed to the function

int func(int a; float b){
    return int(a*b);

float func(float a; float b){
    return a*b;

printf("value is %d", func(2.0, 2.75)); //change the 2.0 to 2 to see the difference


  • Like 2

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this