Vex Question

   1810   4   1
User Avatar
Member
130 posts
Joined: June 2016
Offline
Hello Guys,
I have a weird problem that I couldn't understand,Below is my code,When I query a particular index of a string using string this is working but when I tried this inside a foreach loop It is not working with a variable(pawn i.e iteration number )

Could someone please explain me what Im doing wrong.

string files = 'abcdefgh';
//s@fileN = files[0] //this is working 

int pawnList[];
if (s@pieceName == "pawn"){
    pawnList = expandpointgroup(0, "*");
    foreach (int pawn ; pawnList){
       //s@g = files[0]     // this is working
       s@g = files[pawn]; // this is not working
       //@P = detail(1, sprintf("%s%i",(x[@g],2)));
    }
}

Thanks a lot in advance!
Mohan Pugaz
movfx
https://www.instagram.com/movfx/ [www.instagram.com]
https://www.youtube.com/channel/@_movfx
User Avatar
Member
2528 posts
Joined: June 2008
Offline
Are you running in detail mode?

This simple test worked for me.
string chars = "abcdef";

for(int i=0; i<@numpt; i++) {
    setpointattrib(0,"char",i,chars[i],"set");
}
Using Houdini Indie 20.0
Ubuntu 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
402 posts
Joined: June 2014
Offline
I have a feeling it could be the globbing pattern in expandpointgroup causing the problem, don't think it likes “*”. Try taking the asterisk out
expandpointgroup(0, "")
Henry Dean
User Avatar
Member
8521 posts
Joined: July 2007
Online
not sure what is the expected result here

- if pawnlist has more members than your files string, you'll obviously get “” as in the last iteration you are trying to get element out of range and since you are doing
s@g = files[pawn];
only the last element counts as it's overwriting all previous, that's why
s@g = files[0];
seems to work as you will always overwrite with first index character “a”
- if pawnList has less elements than files string, then you will see the the character at the index of the last element
- since you are using s@pieceName and s@g, I'm assuming you are running per point
that means that every point with s@pieceName==“pawn”, will have the same s@g as all of them would get the same list and unnecessarily iterate over it until they reach last element and use that index to try to get your character, doesn't seem useful
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
130 posts
Joined: June 2016
Offline
Im very sorry that I couldnt reply earlier.

Thank you so much guys I got it working.
Like Thomas said
only the last element counts as it's overwriting all previous, that's why
this is the mistake I did and
I got it working using setpointattrib function as Enivob has did
to change the point number on each iteration.

Also this suggestion from friedasparagus helps to make this work!
friedasparagus
I have a feeling it could be the globbing pattern in expandpointgroup causing the problem, don't think it likes “*”. Try taking the asterisk out
expandpointgroup(0, "")

Thanks a lot for all of you guys.
Mohan Pugaz
movfx
https://www.instagram.com/movfx/ [www.instagram.com]
https://www.youtube.com/channel/@_movfx
  • Quick Links