Jump to content


VEX functions and inline vopsop


  • Please log in to reply
6 replies to this topic

#1 Macha

Macha

    Grand Master

  • Members
  • PipPipPipPipPip
  • 1,653 posts
  • Joined: 23-July 08
  • Location:The Small Big P
  • Name:Marc ♥

Posted 29 May 2012 - 05:28 PM

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, 30 May 2012 - 11:42 AM.

My Vimeo

LinkedIn

improve side effects - use haskell


#2 rdg

rdg

    Houdini Master

  • Members
  • PipPipPipPip
  • 729 posts
  • Joined: 21-August 05
  • Location:weta
  • Name:Georg Duemlein

Posted 30 May 2012 - 12:03 AM

View PostMacha, on 29 May 2012 - 05:28 PM, said:


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.
The Industrial Parametrization of the World
http://rdg.preset.de/

#3 nord3d

nord3d

    Peon

  • Members
  • Pip
  • 50 posts
  • Joined: 19-July 10
  • Name:ALeXeY G.

Posted 14 June 2012 - 04:21 AM

View PostMacha, on 29 May 2012 - 05:28 PM, said:

...

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

#4 mantragora

mantragora

    Initiate

  • Members
  • PipPip
  • 225 posts
  • Joined: 08-December 11
  • Location:frozen hell
  • Name:to be, or not to be, TD ?

Posted 14 June 2012 - 05:28 AM

View Postnord3d, on 14 June 2012 - 04:21 AM, said:

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, 14 June 2012 - 05:30 AM.

magic happens here... sometimes

Vimeo
Twitter

#5 nord3d

nord3d

    Peon

  • Members
  • Pip
  • 50 posts
  • Joined: 19-July 10
  • Name:ALeXeY G.

Posted 14 June 2012 - 07:04 AM

Thanks, mantragora.

So, it is possible, if use Python instead of HScript, for that parameter fields, I understand you correctly?

#6 mantragora

mantragora

    Initiate

  • Members
  • PipPip
  • 225 posts
  • Joined: 08-December 11
  • Location:frozen hell
  • Name:to be, or not to be, TD ?

Posted 14 June 2012 - 07:35 AM

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.
magic happens here... sometimes

Vimeo
Twitter

#7 nord3d

nord3d

    Peon

  • Members
  • Pip
  • 50 posts
  • Joined: 19-July 10
  • Name:ALeXeY G.

Posted 14 June 2012 - 07:49 AM

Thank you again, I will think about it...

Why? -For example, in the asset, user could type an expression, which would be executed in the SOP-node inside...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users