Jump to content
mattjakob

Problem accessing attributes inside For Each Loop

Recommended Posts

uhm... Im trying to avoid using copy stamp as suggested in H16 and use a For Each loop instead... but I cant seem to make sense out of it! (I watched a few videos and checked the help - but they seem pretty useless / over-complicated).

I simply want to copy some geometry (eg. circles) onto some points (eg. on a line) + each point has an attribute --> I scale each geometry based on the point attribute. Seems like a perfect iterative loop over points task!

When I put my copy to point(s) node inside the for each loop everything works fine (the copy node only receives one point which is fed iteratively from the the for loop).

HOWEVER when I apply the transform node and I use vex (@attribute_name) to try to access the attribute value associated to that point to scale my geometry it doesnt work (I get 0).

If I try to access the same attribute using a wrangle node it works.

Maybe Im doing something silly wrong with the transform node... but what I do seems intuitively right (type the vex attrib name in the scale 

 

Thanks!

Screenshot 2017-05-31 12.23.00.png

Share this post


Link to post
Share on other sites

Hello. I assume you are just experimenting, but you do not need copy stamp or for each node for this task. If the points on the line have a pscale attribute on them, the copy to points node will automatically use that to determine the scale of the copy. 

As for the transform node not picking up geometry attributes, I've also had this problem. I'm not sure what the rule is as to when I can just reference attributes in channels and when I can't.

When it doesn't work, you can always use a point expression to acess the attribute. I.e

point("../foreach_begin1", 0, "scaler", 0)

That will pull the point attribute scale off of point number 0 from the node foreach_begin1. 

I hope to see the regular @ notation working across all nodes soon!

Share this post


Link to post
Share on other sites

yup that works...  but REAAALLY ??!!? 

I'd love to know why attribs (nor it's local var equivalent) don't work in the transform node... it's really frustrating

Share this post


Link to post
Share on other sites

I agree. I thought sidefx were in the process of getting vex attributes to work in all channels. The transform node would be a very useful place for them!

Edited by rich_lord

Share this post


Link to post
Share on other sites

For things like the Transform SOP - how would it know which value it should use? You could potentially transform some geometry with thousands of points, with each point having a unique attribute value. Simply using @myattribute should return exactly what, then?

So yes, it won't work with point/primitive attributes - you'd have to use Point SOPs or Primitive SOPs in that case since those work on those individual levels. The Transform SOP works on the detail of the geometry - so what happens if we promote our attribute to detail then? Spoiler, it works just fine using @myattribute in the transform sop when the attribute is a detail attribute.

  • Like 2

Share this post


Link to post
Share on other sites

That makes sense! Even after using Houdini for a fair bit, stuff like this trips me up all the time. 

Share this post


Link to post
Share on other sites

Arrrghh, this thread couldn't be more right on. I was just about to post the very same question.

Cheers;

AJ

Edited by noc2

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

×