Jump to content
Sign in to follow this  
Christoph_H

How to create a geometry parameter in own function?

Recommended Posts

Hi,
how to create a geometry parameter in own function?

In this example the parameter „geo“ should be read a string or an integer. How is this possible?
Because the point function can also read a string or an integer.

function vector TEST (string geo or int geo) {

    vector Ret = point(geo,"ABC",10);
    return Ret;

}

Possibility 1: v@R = TEST("op:../wrangler1'');
Possibility 2: v@R = TEST(1);

Edited by Christoph_H

Share this post


Link to post
Share on other sites

you can overload your function with both possibilities by creating 2 or more functions with the same name but different artument types, amounts or even different return type

vector TEST (string geo) {
    vector Ret = point(geo,"ABC",10);
    return Ret;
}
vector TEST (int geo) {
    vector Ret = point(geo,"ABC",10);
    return Ret;
}

 

Edited by anim

Share this post


Link to post
Share on other sites

well yes and no, obviously you don't want to keep duplicating your function just to change the type

so you can define your functions using pre-processor macros which can be more compact even though a bit ugly

#define F(TYPE) \
vector TEST(TYPE geo) { \
    vector Ret = point(geo,"ABC",10); \
    return Ret; \
} \

F(int)
F(string)
#undef F

 

  • Like 1

Share this post


Link to post
Share on other sites

as that page mentions: 

Quote

The pre-processor supports many of the usual C Pre-Processor directives

so maybe search web for countless examples of C Pre-Processor directives

 

also have a look here:

$HFS/houdini/vex/include/

for some examples implemented by SESI, one of them is for example subdcurve.h

 

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  

×