Hi!
Say, I have a row of cubes and I put down a foreach loop based on connectivity with an attribute wrangle. In this wrangle I want to fetch some info ( like an attribute value) from a previous iteration. How would I do that? Is it even possible to do with foreach loops?
Thanks!
fetching info from a previous iteration in a foreach loop
3466 8 0-
- anon_user_15587529
- Member
- 4 posts
- Joined: June 2023
- Offline
-
- Enivob
- Member
- 2658 posts
- Joined: June 2008
- Offline
-
- anon_user_15587529
- Member
- 4 posts
- Joined: June 2023
- Offline
Enivob
You might want to do that before your copy to points. Move your wrangle after the resample1, and then you can fetch values from @ptnum-1. Still not sure what your final goal is?
my goal is to perform some operation on the current cube using the information i got from the previous cube, if that makes sense.
-
- Lucca
- Member
- 42 posts
- Joined: March 2019
- Offline
nelkhEnivob
You might want to do that before your copy to points. Move your wrangle after the resample1, and then you can fetch values from @ptnum-1. Still not sure what your final goal is?
my goal is to perform some operation on the current cube using the information i got from the previous cube, if that makes sense.
You can create a second for each 'block begin' node and set it to fetch feedback and there you can access the previous iteration
-
- Enivob
- Member
- 2658 posts
- Joined: June 2008
- Offline
-
- anon_user_15587529
- Member
- 4 posts
- Joined: June 2023
- Offline
Enivob
But if the attributes you want to fetch are transferred to the cube by the copy to points creation, you can still operate on those attributes before you generate the geometry.
those points are just placeholders and they dont have the info i need. in my project i dont even use them, the example above is just a basic scenario i came up with. sorry if it's confusing.
LuccanelkhEnivob
You might want to do that before your copy to points. Move your wrangle after the resample1, and then you can fetch values from @ptnum-1. Still not sure what your final goal is?
my goal is to perform some operation on the current cube using the information i got from the previous cube, if that makes sense.
You can create a second for each 'block begin' node and set it to fetch feedback and there you can access the previous iteration
this seems promising. are there any sources demonstrating this in more detail?
-
- tamte
- Member
- 9380 posts
- Joined: July 2007
- Offline
-
- Dougie0047
- Member
- 106 posts
- Joined:
- Offline
Hello nelkh,
you should be able to achieve this if you do some proper sorting before the loop and apply some form of id's according to the sort.
So, in the above example you could make sure that the points are given a sort that reflects how you want things to go through the loop - point0, point1, point2 etc., and then use that to give them id's accordingly - id0, id1, id2 and so on. Transfer this to your cubes, or set up something to do it directly on the cubes if you can.
Then create a second block begin node and set it to fetch input. Connect your points or geo or whatever it is that you want to retrieve information from, to this second block begin. You should now have access to all your geo through this input, and you can from there use the id's.
From your first begin node you'll have your current object, with the current id, and from your second block begin you can then sift out the object/geo/point you want with the current id -1.
If your sorting is a normal numerical sort with int values from 0 to whatever, then that is how your stuff will go through the loop, and thus you can get the current id either from your current object in the loop, or simply use the loops detail attribute "iteration".
Makes sense?
Cheers,
Dag
EDIT: I've now added a small example file to this post. Hopefully this illustrates the above principle well.
you should be able to achieve this if you do some proper sorting before the loop and apply some form of id's according to the sort.
So, in the above example you could make sure that the points are given a sort that reflects how you want things to go through the loop - point0, point1, point2 etc., and then use that to give them id's accordingly - id0, id1, id2 and so on. Transfer this to your cubes, or set up something to do it directly on the cubes if you can.
Then create a second block begin node and set it to fetch input. Connect your points or geo or whatever it is that you want to retrieve information from, to this second block begin. You should now have access to all your geo through this input, and you can from there use the id's.
From your first begin node you'll have your current object, with the current id, and from your second block begin you can then sift out the object/geo/point you want with the current id -1.
If your sorting is a normal numerical sort with int values from 0 to whatever, then that is how your stuff will go through the loop, and thus you can get the current id either from your current object in the loop, or simply use the loops detail attribute "iteration".
Makes sense?
Cheers,
Dag
EDIT: I've now added a small example file to this post. Hopefully this illustrates the above principle well.
Edited by Dougie0047 - Sept. 25, 2023 14:29:41
-
- anon_user_15587529
- Member
- 4 posts
- Joined: June 2023
- Offline
Dougie0047
Hello nelkh,
you should be able to achieve this if you do some proper sorting before the loop and apply some form of id's according to the sort.
So, in the above example you could make sure that the points are given a sort that reflects how you want things to go through the loop - point0, point1, point2 etc., and then use that to give them id's accordingly - id0, id1, id2 and so on. Transfer this to your cubes, or set up something to do it directly on the cubes if you can.
Then create a second block begin node and set it to fetch input. Connect your points or geo or whatever it is that you want to retrieve information from, to this second block begin. You should now have access to all your geo through this input, and you can from there use the id's.
From your first begin node you'll have your current object, with the current id, and from your second block begin you can then sift out the object/geo/point you want with the current id -1.
If your sorting is a normal numerical sort with int values from 0 to whatever, then that is how your stuff will go through the loop, and thus you can get the current id either from your current object in the loop, or simply use the loops detail attribute "iteration".
Makes sense?
Cheers,
Dag
EDIT: I've now added a small example file to this post. Hopefully this illustrates the above principle well.
Thank you so much for taking your time to make a demo. I really appreciate it. I think this method works pretty well for my problem. (:
-
- Quick Links



