Jump to content

findattribval in for loop


logix1390

Recommended Posts

hello,

I am currently studying findattribval vex function and I am trying to do the second example in the help docs here:

http://www.sidefx.com/docs/houdini/vex/functions/findattribval.html

 

I am trying to find point 10 with the id attribute and move it on the y axis by 2 and set the color of that point to red.

I am getting an error...

I will attach my scene for anyone that wants to take a look.

Thank you. 

findattribval.hipnc

Link to comment
Share on other sites

Hi,

Which version of Houdini are you running ? Seems from the doc that H17 allows findattribval to return an array, but from my doc in H16 or H16.5, the signature of that vex fiunction is only int.

So in my opinion, your Wrangle is getting an error because your for loop needs to iterate over an array, while you are feeding it with an integer...

In this case, I would recommend to work with findattribvalcount and then iterate with findattribval(0,"point","id",10, count). See their 3rd example :-)

 

 

Edited by StepbyStepVFX
Link to comment
Share on other sites

Hi Step, thank you for reply. I am currrently using h16 . I might be a little confused on how to get this working. Is there an example you can show me with find attribbval function?

Even with the third example I can't get it working properly. I am trying to make point 10 turn red and move it up on Y.

int count = findattribvalcount(0, "point", "id", 10);
int point_num;
for (int i = 0; i < count; i++) {
    point_num = findattribval(0, "point", "id", 10, i);
    @Cd=set(1,0,0);
    @P.y+=3;
}

This ends up doing it to all the points instead of point 10 only. 

Thank you.

 

Link to comment
Share on other sites

I tested 16.0 and 16.5....errors

H17 works fine.

For your last effort, try this:

int count = findattribvalcount(0, "point", "id", 10);
int point_num;
vector newpos;
for (int i = 0; i < count; i++) {
    point_num = findattribval(0, "point", "id", 10, i);
    setpointattrib(0, "Cd", point_num, {1,0,0}, "set");
    newpos = point(0, "P", point_num) + {0,3,0};
    setpointattrib(0, "P", point_num, newpos, "set");
    //@Cd=set(1,0,0);
    //@P.y+=3;
}

(note: even tho H17 works without errors...logically it is still wrong as it affects EVERYTHING......instead of just one point, hence it needs same logic as my solution above)

Link to comment
Share on other sites

Thank you Noobini , this works.

This is the first time I am using this function. Is it possible to get the second example in the help docs to work in 16.5 ?

Help docs example:

for (int point_num : findattribval(0, "point", "age", 10))
{
    // ...do something with the point...
}


I guess I am just trying to simplify this as much as possible for a better understanding. 

Thank you for the help

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