Jump to content
Sign in to follow this  
noc2

Variable with its enumerator in VEX

Recommended Posts

Hi;

 

I have a small vex snippet like below:

vector P1 = point(0, "P", 0);
vector P2 = point(0, "P", npoints(0)-1);

int btmSide1 = addpoint(geoself(), set(P1.x, P1.y-1, P1.z));
setdetailattrib(0, "btmSide", btmSide1, "append");
int btmSide2 = addpoint(geoself(), set(P2.x, P2.y-1, P2.z));
setdetailattrib(0, "btmSide", btmSide2, "append");

The btmSide1 and 2 variables return ID's of the points created and I'm placing those points one by one into an integer array named "btmSide". I want to be able to do this in a for loop but got stuck with names :( How can I denote the enumerator beside the name "btmSide" and have it recognized as an integer?

 

Thanx so much for the help in advance :)

 

Cheers;

 

AJ 

Edited by noc2

Share this post


Link to post
Share on other sites

Hi Aj!

 

I'm not the most knowledgeable person but here are a few things that might help >

 

#1

You're wanting to convert btmside2 to an integer to append it to the array btmside? 

If you're stuck on "names" perhaps you should use strings instead? 

If you want to use the name btmside and convert btmside2 to an integer and append it to the end of btmside, sprintf is perfect for you! (I think)

 

String btmside = sprintf(“%s%d”, btmside, integer);

 

#2 

Have you checked if your wrangle is running over points vs detail?

#3

 

I'm still learning vex as well, but this method might be of use to you >

Whenver I run over points in a loop and I want specific points to do specific things, I just check if the point number is = to the looping number.

for (int i = 0; i<@numpt; i++) {

if (i == @ptnum) {

setpointgroup(0,btmside,i,0);

}

}

 

Let me know if any of this helped, or if I'm just stupid. 

Good luck!

Edited by MitchFields
  • Like 1

Share this post


Link to post
Share on other sites

if I understood the question correctly, you are trying to generate an array of integers with newly created points:

You have to run over detail only once.

vector P;
int btmSideArray[];
for (int i=0;i<@numpt;i++){
    P = point(0, "P", i);
    int btmSide = addpoint(0, set(P.x, P.y-1, P.z));
    append(btmSideArray, btmSide);
    setdetailattrib(0, "btmSide", btmSideArray, "set");
}

hip file attached.  

appendarray.hip

Edited by Hickstein
  • Like 1

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
Sign in to follow this  

×