Jump to content
Jim_M

Custom attribute in a for each loop

Recommended Posts

Ok so just when I thought I had got my head around for each loops, I am struggling to get a custom attribute into a transform.

The attribute is certainly seen by the copy to points node. and when I try to detail it in the transform, it justs gives back a zero.

I've tried by including the transform in the for each loop, with a block begin fetch input etc. Makes no difference.
(Using the spare input and -1 tag instead of the "../iteration".

I've tried all combinations of cases @ signs, $ signs and whatever else.

The "global attributes" colour and the scale nodes work fine.
 

effector.thumb.jpg.fb174762e53f3d0df885923d9fbd5755.jpg

effector_v003.hip

Share this post


Link to post
Share on other sites

3Dome, thank you very much indeed.

Of course. detail = detail. 
I am idoit.

All is clear(er).

I don't know why I thought I needed to reference iterations. I think it's because I was previously creating geometry and scaling each iteration, and I just got confused. And if you were working on primitive attributes you would use prim(surface_node, prim_num, attrib_name, attrib_index) 

So the point number is obviously 0 as there is only one box coming in, and its just referencing the incoming transform (& attribute) in the copyToPoints node for each copy based on the templated points?

And if I wanted to use a 3 value float Attribute for scale, instead of a transform sop I would use a point vop and somehow get the attribute inside that?

Any idea why using the pack option on the copyToPoints node loses the colour attribute?

Many thanks,

Jim

 

Edited by Jim_M

Share this post


Link to post
Share on other sites
2 hours ago, Jim_M said:

So the point number is obviously 0 as there is only one box coming in, and its just referencing the incoming transform (& attribute) in the copyToPoints node for each copy based on the templated points?

No. The point number is 0 because the loop runs over each point of the grid, so for each iteration there is only 1 point => ptnum = 0
That point has your effector attribute, which is read by the point()-expression in the transform SOP to modify the box size. Then it gets copied onto the current point's position.
Iteration done.
Next iteration: same process but new point => different effector value, different position to copy the box to.
After the loop has run through all points of the grid, it outputs the merged boxes as the result.

2 hours ago, Jim_M said:

And if I wanted to use a 3 value float Attribute for scale, instead of a transform sop I would use a point vop and somehow get the attribute inside that?

You can still use the transform for that. If you have a vector attrib called effector just change the attrib_index in the point expression to 1=y and 2=z

 

2 hours ago, Jim_M said:

Any idea why using the pack option on the copyToPoints node loses the colour attribute?

In 16.5.536 when I tick on Pack and Instance it keeps the color. Previous version had some "issues" with displaying packed color, apparently SideFX now made some changes.
Anyway, if you unpack your stuff later the color attrib should be back.

Share this post


Link to post
Share on other sites

Thanks for the clarity, that does help a lot.
 

1 hour ago, 3dome said:

You can still use the transform for that. If you have a vector attrib called effector just change the attrib_index in the point expression to 1=y and 2=z

 

Ahhhhh of course. Great.

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

×