Jump to content

VEX functions and inline vopsop


Macha

Recommended Posts

I have 2 questions regarding vex and the inline vopsop.

-Is it possible to define a function in the inlinevop and then call it as well? Something along the lines of:

float f(float x, float y){ return x*y; }
z=f(12.0,23.0);
printf("z:%f ",z);

We can do this with a Vex builder type by putting the functions in the outer code section if I remember correctly. But how about inline vop?

-Is there a way to turn a string into a vex expression? For example, a user would enter "x^2" as a parameter and we could use it as

x^2 

in the code.

Thanks!

Edited by Macha
Link to comment
Share on other sites

f(float x, float y){ return x*y; }
z=f(12.0,23.0);
printf("z:%f ",z);

You can specify an external header file on the inlineVOP.

As far as I know this can't be part of an HDA section and probably want to sit somewhere in $HOUDINI_PATH/vex/include.

Maybe helps.

Link to comment
Share on other sites

  • 3 weeks later...

...

-Is there a way to turn a string into a vex expression? For example, a user would enter "x^2" as a parameter and we could use it as

x^2 

in the code.

Thanks!

Hi there,

How about the second question? It is also very interesting to me.

As well as a way to execute a string in the one parameter's field as an expression in other parameter's field. I have tried eval(), but without success.

Link to comment
Share on other sites

Guest mantragora

Hi there,

How about the second question? It is also very interesting to me.

As well as a way to execute a string in the one parameter's field as an expression in other parameter's field. I have tried eval(), but without success.

Not possible. For things like this you need interpreted/dynamic language. That means that, in Houdini world, Python is your answer.

Edited by mantragora
Link to comment
Share on other sites

Guest mantragora

1. You can create your own expressions in "Edit->Aliases and Variables->Expression" Tab. Maybe this is what you are looking for.

2. Why do you need this ? x^2 will not execute pow() function in Python without making comparisons with if:...elif:... so it's still not useful. You can probably add aliases to python classes that will allow something like this, but it will make bigger mess, for you to manage, than help.

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...