Trouble accessing local attributes in foreach loop

   2184   6   2
User Avatar
Member
73 posts
Joined: 4月 2020
Online
Dear Experts,

I have a foreach by number loop in which I'd like to set the number of iterations to the value of a previously calculated attribute "@loopIter".
This attribute is visible in the geometry spreadsheet on the foreach_begin node and subsequent nodes in the loop, except for the foreach_end node, which is where I need it to give its value to the "Iterations" parameter. When I right click on the Iterations parameter and use the Reference menu option, I can sometimes see this attribute as being visible as a point attribute. Sometimes it is not listed, and I don't know what influences its visibility. When it is listed, though, and I select it, it gets a value of 0 rather than the correct value, so I guess it's not really there.

Should it be? If so, what am I doing wrong? Am I not approaching this problem correctly?

Thanks so much,
Mary

Attachments:
test_iter.hip (144.8 KB)

User Avatar
Member
555 posts
Joined: 2月 2017
Offline
a bit convoluted trying to guess your aim so i could be on the wrong track....sue me.

just go into the control and drag around Target. Naturally, you can adjust Iter Distance too.

(just doublecheck if you need to + 1 in the points in the line creation ie. if you want a line to have 4 divisions, then it has 5 points)
Edited by vusta - 2021年5月29日 22:27:01

Attachments:
vu_thingie.hipnc (112.0 KB)

User Avatar
Member
73 posts
Joined: 4月 2020
Online
Thanks, vusta. I guess that is a different way to approach it -- copy the grid to each place first, then iterate across the grids doing what my null ("do_some_things") placeholder represents. I'll give that a shot.

I'm still curious, though, if anyone knows how to get the access to local attributes to work in the foreach_end parameter!

Thanks again,
Mary
User Avatar
Member
670 posts
Joined: 9月 2013
Online
Hi Mary,

I think you would rather set the number of iterations to a detail attribute. Then access its value using the corresponding expression:

detail('../volume_size', 'loop_iterations', 0)
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
73 posts
Joined: 4月 2020
Online
Thanks, Konstantin -- indeed in VEX that is what I would usually do. But if I were to try to make use of the foreach SOP -- how do I access that attribute in the foreach_end SOP Iterations parameter to set the iteration count? The attribute doesn't seem to be available whether it's a point attribute, detail attribute, or primitive attribute...

Thanks again,
Mary
User Avatar
Member
555 posts
Joined: 2月 2017
Offline
well if you put

point(0,0,"loopIter",0)

in the Iterations at the end, you'll get 4

change your Distance in control to 0.25 and you'll get 8 iterations

(probably a bit confusing when you say local attributes tho, the loopIter are attributes that are readily widely avail, not just temporary local to some wrangle)
Edited by vusta - 2021年5月30日 17:34:51
User Avatar
Member
17 posts
Joined: 11月 2019
Offline
Konstantin Magnus
Hi Mary,

I think you would rather set the number of iterations to a detail attribute. Then access its value using the corresponding expression:

detail('../volume_size', 'loop_iterations', 0)

I'm giving this a like because it helped me out!
  • Quick Links