Jump to content
Sign in to follow this  
wateryfield

The node name and font content

Recommended Posts

1. I wonder why the node name can't be digital-only, such as 1, 2 or 10.1.

 

2. And another problem, i want create a font with content was the number of the node name, such as the node name was s11 , the font content was 11, how can i get the number,  opdigits(`$OS`) not working at font.

 

3. I can get the name by $OS in Hscript, how to get the node name use VEX, and where can i find all the VEX attributes? 

 

Any help will be appreciated.

Thanks!

 

Share this post


Link to post
Share on other sites

1. probably the same reason why variable in any programming language can't be a number, how would you distinguish between variable and number?

 

2. as you are putting expressions into string field, you need to use ticks

`opdigits($OS)`

3. you can create string parameter and put $OS in there

or in wrangle snippets you can insert `$OS` into your code like

string name = `$OS`;

or in shading context you can use getobjectname() finction

 

not sure what you mean by all VEX attributes, here are some links:

http://www.sidefx.com/docs/houdini13.0/vex/contexts/

http://www.sidefx.com/docs/houdini13.0/vex/snippets

http://www.sidefx.com/docs/houdini13.0/vex/functions/

  • Like 1
  • Sad 1

Share this post


Link to post
Share on other sites

1. probably the same reason why variable in any programming language can't be a number, how would you distinguish between variable and number?

 

2. as you are putting expressions into string field, you need to use ticks

`opdigits($OS)`

3. you can create string parameter and put $OS in there

or in wrangle snippets you can insert `$OS` into your code like

string name = `$OS`;

or in shading context you can use getobjectname() finction

 

not sure what you mean by all VEX attributes, here are some links:

http://www.sidefx.com/docs/houdini13.0/vex/contexts/

http://www.sidefx.com/docs/houdini13.0/vex/snippets

http://www.sidefx.com/docs/houdini13.0/vex/functions/

 

 

Anim, Thanks for your super fast respond.

There is too much thing i have to learn.

:)  

I will have a try soon!

  • Like 1

Share this post


Link to post
Share on other sites

1. probably the same reason why variable in any programming language can't be a number, how would you distinguish between variable and number?

 

2. as you are putting expressions into string field, you need to use ticks

`opdigits($OS)`

3. you can create string parameter and put $OS in there

or in wrangle snippets you can insert `$OS` into your code like

string name = `$OS`;

or in shading context you can use getobjectname() finction

 

not sure what you mean by all VEX attributes, here are some links:

http://www.sidefx.com/docs/houdini13.0/vex/contexts/

http://www.sidefx.com/docs/houdini13.0/vex/snippets

http://www.sidefx.com/docs/houdini13.0/vex/functions/

Anim, I get a problem.

 

Is  `$OS` can direct insert into wrangle .

string name = `$OS`;
s@s = name;

or

s@s = `$OS`;

It not working, or i was a wrong syntax.

 

And the getobjectname() finction   , I confuse with the   

 

 

  1. string getobjectname()

Returns the name of the current object whose shader is being run, or the empty string if there is no current object. 

 What mean whose shader is being run?

Thanks!

Edited by wateryfield

Share this post


Link to post
Share on other sites

There is too much thing i have to learn.

:)  

 

However much one learns, this is still true :)

Share this post


Link to post
Share on other sites

Is  `$OS` can direct insert into wrangle .

string name = `$OS`;
s@s = name;

It not working, or i was a wrong syntax.

 

 

 

 

I don't think there is a VEX function that will let you grab the node name but an easy workaround is to edit the parameter interface (via the gear button) and add a string parameter to your node.

Let's call it operator_name

In the new created field you can type $OS to access the name you want.

It is now accessible in your VEX code via the ch() function.

s@my_name = ch("operator_name");

EDIT : after anim answer (below), I learnt that you can actually easily access '$' variable with simple double quotes... thanks :)

Edited by iamyog
  • Like 1

Share this post


Link to post
Share on other sites

...

string name = `$OS`;
s@s = name;
or

s@s = `$OS`;
It not working, or i was a wrong syntax.

...

 

my mistake, I was writing from top of my head instead of checking in H

this is the correct syntax

string name = "$OS";

the $OS gets expanded and inserted into VEX code before that get's compiled.

it wouldn't work with animated variables as VEX is compiled only on first frame, but $OS is not changing so it should be safe

 

 

...

And the getobjectname() finction   , I confuse with the   

 What mean whose shader is being run?

Thanks!

it means it returns the name of the object that the shader belongs to/is called from

so if you have 2 objects A and B and you assign the same shader to them with getobjectname() function inside

that function returns A when evaluating that shader on object A and B when evaluating it on B etc.

  • Like 1

Share this post


Link to post
Share on other sites

However much one learns, this is still true :)

 

Houdini is huge ball of threads -- pick one and start pulling....

Share this post


Link to post
Share on other sites

I don't think there is a VEX function that will let you grab the node name but an easy workaround is to edit the parameter interface (via the gear button) and add a string parameter to your node.

Let's call it operator_name

In the new created field you can type $OS to access the name you want.

It is now accessible in your VEX code via the ch() function.

s@my_name = ch("operator_name");

EDIT : after anim answer (below), I learnt that you can actually easily access '$' variable with simple double quotes... thanks :)

Thanks, it is a good idea.

And anim 's answer working well too.

 

string name = "$OS";

Share this post


Link to post
Share on other sites

my mistake, I was writing from top of my head instead of checking in H

this is the correct syntax

string name = "$OS";

the $OS gets expanded and inserted into VEX code before that get's compiled.

it wouldn't work with animated variables as VEX is compiled only on first frame, but $OS is not changing so it should be safe

 

 

it means it returns the name of the object that the shader belongs to/is called from

so if you have 2 objects A and B and you assign the same shader to them with getobjectname() function inside

that function returns A when evaluating that shader on object A and B when evaluating it on B etc.

Thanks.

Working!

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  

×