How to get point position string?

   2622   11   2
User Avatar
Member
63 posts
Joined: 2月 2022
Online


There is a straight line and I can get the position information of each point through vex.



I want to put the position (string) of each point at the corresponding position through copytopints, but I don’t know how to get this position information in the font node. Do you have any good ideas?



I can get position information in font node with only one point,

There is nothing you can do after the number of points increases, and the font node only has an output port and cannot be nested in a loop.

Thank you for your help!
Edited by HenDaSheng - 2023年10月25日 11:19:31

Attachments:
Get_PosText.hiplc (169.6 KB)

User Avatar
Member
8839 posts
Joined: 7月 2007
Offline
something like this

Attachments:
Get_PosText_fix.hipnc (154.1 KB)

Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
63 posts
Joined: 2月 2022
Online
坦特
something like this
This completely solved my problem.
This is the first time I know how to use font node -> Spare Input. Thank you very much for your help!
User Avatar
Member
63 posts
Joined: 2月 2022
Online
HenDaSheng
坦特
something like this
This completely solved my problem.
This is the first time I know how to use font node -> Spare Input. Thank you very much for your help!

I hurriedly replied after seeing the effect. I only discovered the problem when I tried it myself (it's not a problem with tamte's answer, it's my own problem).



It turns out that "Spare Input" is a custom parameter interface, and its parameter type directly affects the final effect. This is very new knowledge to me. I will study it carefully and I think it will be used in other places.
User Avatar
Member
274 posts
Joined: 7月 2013
Offline
You can use also use a merge node inside the for-loop. If you set the loop up in feedback mode the merge will add a font output in each iteration.
More code, less clicks.
User Avatar
Member
4731 posts
Joined: 2月 2012
Offline
You can also do this without a for loop network using some VEX:

string pos [ ] = { };
int count = npoints ( 0 );

for ( int i = 0; i < count; ++i )
{
    vector p = point ( 0, "P", i );
    append ( pos, sprintf ( "%s", p.y ) );
}

s@pos = join ( pos, "\n" );

Then read the string attribute from the Font SOP:

`details(-1, "pos")`

Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
User Avatar
Member
8839 posts
Joined: 7月 2007
Offline
HenDaSheng
It turns out that "Spare Input" is a custom parameter interface, and its parameter type directly affects the final effect. This is very new knowledge to me. I will study it carefully and I think it will be used in other places.
here is some info on spare inputs https://www.sidefx.com/docs/houdini/model/compile.html#spare [www.sidefx.com]
they are susally used within compiled blocks as that has many restrictions, but they are useful overall to refer to other nodes without having to type the path to the node in every expression
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
63 posts
Joined: 2月 2022
Online
animatrix_
You can also do this without a for loop network using some VEX:

string pos [ ] = { };
int count = npoints ( 0 );

for ( int i = 0; i < count; ++i )
{
    vector p = point ( 0, "P", i );
    append ( pos, sprintf ( "%s", p.y ) );
}

s@pos = join ( pos, "\n" );

Then read the string attribute from the Font SOP:

`details(-1, "pos")`


This is also very new knowledge to me. Thank you for your help, it gives me more choices. I will study this method carefully!
User Avatar
Member
63 posts
Joined: 2月 2022
Online
tamte
HenDaSheng
It turns out that "Spare Input" is a custom parameter interface, and its parameter type directly affects the final effect. This is very new knowledge to me. I will study it carefully and I think it will be used in other places.
here is some info on spare inputs https://www.sidefx.com/docs/houdini/model/compile.html#spare [www.sidefx.com]
they are susally used within compiled blocks as that has many restrictions, but they are useful overall to refer to other nodes without having to type the path to the node in every expression





I tried to perform certain processing on the string through vex (limiting the number of digits after the decimal point), but introducing new variables in the font node did not work.

I think it's something outside of my knowledge. I guess the problem is with the new variables because they don't appear in the spreadsheet when the font node is selected.
Edited by HenDaSheng - 2023年10月26日 07:55:35
User Avatar
Member
63 posts
Joined: 2月 2022
Online
Jonathan de Blok
You can use also use a merge node inside the for-loop. If you set the loop up in feedback mode the merge will add a font output in each iteration.

Thanks for the idea, I'll try it out.
User Avatar
Member
144 posts
Joined: 8月 2012
Offline
HenDaSheng
I tried to perform certain processing on the string through vex (limiting the number of digits after the decimal point), but introducing new variables in the font node did not work.

I think it's something outside of my knowledge. I guess the problem is with the new variables because they don't appear in the spreadsheet when the font node is selected.

Use the points() expression instead as it outputs a string attribute. The Text field of the Font SOP is a string field.
User Avatar
Member
8 posts
Joined: 8月 2017
Offline
HenDaSheng
I tried to perform certain processing on the string through vex (limiting the number of digits after the decimal point)

try this in font sop:
pos.y = `substr(point(-1, 0, 'pos_y_str', 1), 0, 4)`
  • Quick Links