spectronaut Posted May 10, 2017 Share Posted May 10, 2017 I'll get right to it. I am running a foreach loop on a bunch of prims. For each prim I scatter a number of points. Still within the foreach loop, I run a point wrangle on those points. In the wrangle I run intersect on each of the points and if one hits I want to set an attribute on the prim (foreach loop peice) that the points were scattered on. In the end I don't need the scattered points, I just need the prims output with the attribute @keepage. What I cant figure out is how to set up the forloop so that this works. Quote Link to comment Share on other sites More sharing options...
spectronaut Posted May 11, 2017 Author Share Posted May 11, 2017 Obviously this loop will output points. The VEX for the wrangle "secondaryIntersect" seems valid, but I have no way of applying the attribute to the iteration pieces (primitives). VEX for "secondaryIntersect" running over primitives. vector p; vector hitprimuvw; vector srcpt; i@ptrefprim = prim(2, "refprim", 0); srcpt = v@P + (normalize(v@rdir)*2); i@hitprim = intersect(1, srcpt, v@rdir, p, hitprimuvw); if(@hitprim<5){ setprimattrib(2, "keepage", 0, 1, "set"); } Quote Link to comment Share on other sites More sharing options...
spectronaut Posted May 11, 2017 Author Share Posted May 11, 2017 This makes me think my approach is not possible. https://www.sidefx.com/forum/topic/42999/ Quote Link to comment Share on other sites More sharing options...
kgmcnamara Posted May 11, 2017 Share Posted May 11, 2017 Given what you currently have, you could make secondaryIntersect set a detail attribute on itself that marks whether or not an intersection happened. Then, disconnect the output of secondaryIntersect from the foreach_end. Drop an attribute create, linking foreach_begin -> secondaryIntersect -> foreach_end, and set the attribute create to look at the detail attribute that secondaryIntersect set, thus marking the current prim with whether or not the intersection happened. Might not necessarily be the most computationally efficient way, but maybe the easiest thing to do given the current setup. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.