Jump to content

Variable with its enumerator in VEX


noc2

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
Link to comment
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
Link to comment
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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...