Jump to content
mrcoolmen

Question on loop through attribute in vops.

Recommended Posts

Hey Guys,

 

Just wondering how to do the operation like foreach(attribute) in Vops?

 

thanks for your help in advance :)

 

Cheers

Kevin

Share this post


Link to post
Share on other sites

You can do this but to get/set attribute values generically you will have to write a ton of code or nodes in VOPs.

Share this post


Link to post
Share on other sites

You can use the Find Attribute Value Count Vop, this will return the number of unique values contained within a String or Integer. You can use this to run a For Loop and inside you'll hook up i to Find Attribute Value by Index node to pull the current value. Just be aware, running this is in a Attrib VOP set to run on Detail (Only Once) will be analogous to the old ForEach sop. If you run it on points you'll be iterating numpts^numattribs (an assload) times, so if you have a high point count you should avoid doing that. 

Share this post


Link to post
Share on other sites

Hey Guys,

 

Thanks so much for your help, this is a really awesome houdini community.

 

Just wondering if your guys can help a give a v quick example file?

 

i did try myself but did not really get it to work.

 

Really appricate ur all help.

Share this post


Link to post
Share on other sites

What exactly are you trying to do? There's a lot of alternate ways to accomplish this sort of thing. 

Share this post


Link to post
Share on other sites

What exactly are you trying to do? There's a lot of alternate ways to accomplish this sort of thing. 

 

 

 

Hey Jesse,

 

I know there are a lot of alternate ways to accomplish same thing, im jt curious and wish to gain some knowledge about the for loop & for each node.

 

This is the example i will wish your guys can help me out. It is jt  use a unique attribute to connect 2 points more points,

 

 

i know "add" can achieve same effect but like i said, im super curious about it.

 

Thank you guys in advance for helping me learning this software

exmaple.hip

Share this post


Link to post
Share on other sites

Loops in vops/sops hurt my brain, but I figure its good practice. :)

 

Had to write them out in vex first, then use that as a guide to do the vop versions. Something not right about them (they generate twice as many prims as required), but it should get you going.

 

vop_loops.hipnc

  • Like 1

Share this post


Link to post
Share on other sites

Just gonna pod onto Matt's file here with a Find Attribute Value by Index example. This uses an If statement to acheive the same results as running through a loop, but you can use the Find Attribute Value Count vop to set up a loop that will do something similar.

 

@Matt, the reason for the difference in prim numbers can be seen if you look at the primitive numbers before the fuse. The first method creates one legitimate edge and one degenerate zero-length edge. The second method creates two legitimate primitives so the Fuse doesn't remove anything.

vop_loops.hipnc

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

×