I am trying to get a line that is only allowed to go up or down. It might be the ForLoop i wrote that is handled different from what i am expecting:
intnumPoints = @numpt;
for (inti = 0;i < numPoints;i++)
{vectorcurrentPos=point(0,"P",i); //get the prev point positionvectorlastPos=point(0,"P",i-1); //get the second to last point positionif (currentPos.y >= lastPos.y)
{vectornewPos = (currentPos.x,lastPos.y,currentPos.z);
setpointattrib(0,"P",npoints(0)-1,newPos); //write the newPos}}
i am expecting every point to be under or above the Y value of its previous point, but for some reason nothing happens, only the last point in the line is altered. When i transform the Line i am using to have Y values above 0 only, some y values are set but not in a manner that makes sense.
Well for one, when you use the setpointattrib you are only ever assigning the last point number (npoints(0)-1) a value.
Second, I'm not sure what you are trying to accomplish, because by 'default' any point will have a Y value that is either above or below the previous point; except in cases where they have the same Y value. But your code doesn't seem to be attempting to address the cases in which the Y value is the same.
Are you simply wanting all points to have the same x and z values, ie. ensure a vertial 'y' line?
Perhaps you could re-state what you are trying to accomplish with a hip file and someone might offer a solution. Remember too that in reworking your code if your wrangle is running in points mode and your setting point positions, you are going to get odd results since that code will be run for every point concurrently with a number of other points having the same code run on them too.(parallel processing is done with points/primitive modes) - Detail mode might be better depending on what your final attempt is.