Jump to content

How to create a geometry parameter in own function?


Christoph_H

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
Link to comment
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
  • Like 1
Link to comment
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 2
Link to comment
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

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...