noc2 Posted December 8, 2018 Share Posted December 8, 2018 (edited) 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 December 9, 2018 by noc2 Quote Link to comment Share on other sites More sharing options...
MitchFields Posted December 13, 2018 Share Posted December 13, 2018 (edited) 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 December 13, 2018 by MitchFields 1 Quote Link to comment Share on other sites More sharing options...
hall Posted December 13, 2018 Share Posted December 13, 2018 (edited) 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 December 13, 2018 by Hickstein 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.