point function to print point x positions using for loop

   2271   1   1
User Avatar
Member
59 posts
Joined: Nov. 2014
Offline
trying to print the position x values of the points to the houdini console using point function

for (int i = 0 ; i <= @ptnum ;i++) 

float b = float point(0,i,"P",0);

printf("for ptnum %d x value is %d\n",@ptnum,b);

getting an error,
looking for corrections,
what is to be added or altered to the current code
thank you in advance

realised above point function is expression in hscript, And then i tried with the below code of point vex function still showing some error at printf function
 float b = point(0,"P.x",0); 

strange with this
float b = point(0,"P.x",0);

printf("for ptnum %d x value is %d\n",@ptnum,b);
it printed like this
for ptnum 0 x value is 0
for ptnum 1 x value is 0
for ptnum 2 x value is 0
for ptnum 3 x value is 0
for ptnum 4 x value is 0
for ptnum 5 x value is 0
for ptnum 6 x value is 0
for ptnum 7 x value is 0
looking for corrections

i tried only with the printf function to print the @ptnum and @P.x

printf("for ptnum %d x value is %d\n",@ptnum,@P.x);

it worked and printed like this
for ptnum 0 x value is -0.5
for ptnum 1 x value is 0.5
for ptnum 2 x value is 0.5
for ptnum 3 x value is -0.5
for ptnum 4 x value is -0.5
for ptnum 5 x value is 0.5
for ptnum 6 x value is 0.5
for ptnum 7 x value is -0.5
but if i use the for loop it is not working
Edited by Sweetener - Sept. 9, 2018 13:06:34

Attachments:
x value.hipnc (67.2 KB)

Houdini Fx Artist (Build)
User Avatar
Member
209 posts
Joined: March 2018
Offline
Hello mate.
try something like:
vector b = point(0, 'P', 0);
printf("x pos is: %d", b.x);

Indeed you should read a vector attribute P and then assign it to a vector variable.
VCC can't understand what you want from it!
If you want to use x position on the fly, following form can be used:
printf("x pos is: %d", vector(point(0, 'P', 0).x));
Hope this helps.
  • Quick Links