vector pos = point(0, "P", 6);
int npts = nearpoints(0, pos, 1.5);
printf("%s\n", npts);
foreach(int npt; npts){
if(npt == 6 || npt == 1){
removevalue(npts, npt);
}
}
printf("%s\n", npts);
===========result:
{6, 1, 5, 7, 11}
{1, 5, 7, 11}
Why point 1 cannot be removed
why Some point number cannot be removed from the array
389 4 1- luotexia2310
- Member
- 3 posts
- Joined: 2月 2023
- Offline
- animatrix_
- Member
- 4521 posts
- Joined: 2月 2012
- Offline
Hi,
You shouldn't modify the array you are looping over when using foreach loop. You don't have to loop over the elements like that to remove values. Just do like this:
Or loop over the elements to remove:
You shouldn't modify the array you are looping over when using foreach loop. You don't have to loop over the elements like that to remove values. Just do like this:
removevalue ( npts, 6 ); removevalue ( npts, 1 );
Or loop over the elements to remove:
int elements [ ] = { 6, 1 }; foreach ( int element; elements ) removevalue ( npts, element );
Edited by animatrix_ - 2024年4月12日 11:24:47
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]
youtube.com/@pragmaticvfx | patreon.com/animatrix | pragmaticvfx.gumroad.com
- Tanto
- Member
- 396 posts
- Joined: 11月 2016
- Offline
- luotexia2310
- Member
- 3 posts
- Joined: 2月 2023
- Offline
动画师_
Hi,
You shouldn't modify the array you are looping over when using foreach loop. You don't have to loop over the elements like that to remove values. Just do like this:removevalue ( npts, 6 ); removevalue ( npts, 1 );
Or loop over the elements to remove:int elements [ ] = { 6, 1 }; foreach ( int element; elements ) removevalue ( npts, element );
I understand, thank you very much!
- luotexia2310
- Member
- 3 posts
- Joined: 2月 2023
- Offline
-
- Quick Links