algorithmic modeling for Rhino
i am a new beginner to use the code?
so , How can i start the code?
just like this code! is this any other method or better code to solve this problem?
1. Solution exception:Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
List<Point3d> pList = new List<Point3d>(){p1,p2,p3,p4,p5,p6};
for(int i = 0, i<pList.Count;i++){
Point3d pCurrent = pList[i];
Point3d pNext;
try{pNext = pList[i+1];} catch{pNext = pList[0];} // meaning the obvious, he he
Line line = new Line(pCurrent, pNext);
... blah, blah ...
}
List<Point3d> pList = new List<Point3d>(){p1,p2,p3,p4,p5,p6};
for(int i = 0, i<pList.Count;i++){
Point3d pCurrent = pList[i];
Point3d pNext;
try{pNext = pList[i+1];} catch{pNext = pList[0];} // meaning the obvious, he he
Line line = new Line(pCurrent, pNext);
... blah, blah ...
}
Tags:
You can use an if statement to check if you are dealing with the last element of the list
Another way would be:
List<Point3d> pList = new List<Point3d>(){p1, p2, p3, p4, p5, p6};
pList.Add(pList[0]);
for(int i = 0, i < pList.Count - 1; i++){
Point3d pCurrent = pList[i];
Point3d pNext = pList[i+1];
Line line = new Line(pCurrent, pNext);
... blah, blah ...
}
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by