Christoph_H Posted December 16, 2019 Share Posted December 16, 2019 (edited) 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 December 17, 2019 by Christoph_H Quote Link to comment Share on other sites More sharing options...
anim Posted December 16, 2019 Share Posted December 16, 2019 (edited) 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 December 16, 2019 by anim 1 Quote Link to comment Share on other sites More sharing options...
Christoph_H Posted December 17, 2019 Author Share Posted December 17, 2019 Thanks. Is this generally the way to solve this possibility during programming? Quote Link to comment Share on other sites More sharing options...
anim Posted December 17, 2019 Share Posted December 17, 2019 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 2 Quote Link to comment Share on other sites More sharing options...
Christoph_H Posted December 17, 2019 Author Share Posted December 17, 2019 (edited) Thanks. I'm wondering a bit, because I can't find the syntax on the corresponding page like this. https://www.sidefx.com/docs/houdini/vex/vcc.html How can I find that out, except on forums? Edited December 17, 2019 by Christoph_H Quote Link to comment Share on other sites More sharing options...
anim Posted December 17, 2019 Share Posted December 17, 2019 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.