Jump to content

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!

 

Link to comment
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
Link to comment
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
Link to comment
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
Link to comment
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
Link to comment
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
Link to comment
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";

Link to comment
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!

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