algorithmic modeling for Rhino
Ok I'm going to preface this by saying I'm a complete newb at this. I finished watching some tutorials and thought I would try my hands at something simple.
I'm trying to recreate the python script used in this video to C#
http://vimeo.com/album/2282897/video/60606151
I keep getting errors at my for statement and I don't know why. I think I'm doing it right...
Here is my code so far and I'm attaching my file.
private void RunScript(List<Point3d> allpts, int iterations, ref object u)
{//Get the first point in the list
Point3d firstpt = allpts.Interval(T0);
//Remove the first point from the list
allpts.Remove(firstpt);
//Creates a list for the used points
List<Point3d> used = new List<Point3d>();
//Loops through iterations
For(iterations = 0; iterations < allpts.Interval(T1); iterations++){
//Gets the closest point in the list from the first point and adds it to the used while removing it from allpts
Point3d nextpt = Rhino.Collections.Point3dList.ClosestIndexInList(List < allpts > list, firstpt);
allpts.Remove(nextpt);
used.Add(nextpt);
}
//Output the list of the visited points
u = used;
Thanks in advance for any help. Maybe I should have just started with python instead :(
Tags:
Lower case 'f' in for?
--
David Rutten
david@mcneel.com
Also iterations as a variable isn't declared anywhere a far as I can tell.
for (int iterations = 0; iterations < allpts.Interval(T1); iterations++)
--
David Rutten
david@mcneel.com
Hi David! You were right it was a lowercase "f". I feel so stupid...Although this now created 7 more errors which I tried to fix.
All I'm trying to do is get access to the first point, the last point and the next point in a list, but it won't let me do so. So I tried making an array because it gives me a handy command to get the last and first items, but now it created a "syntax error" at the first line. Is there a way to get the last and first items in a list without doing an array? Because even if I fix the syntax error, I still have to provide a value inside the [].
Point3d[] arraypts = allpts[];
Point3d fpt = arraypts.First;
//Remove the first point from the list
allpts.Remove(fpt);
//Creates a list for the used points
List<Point3d> used = new List<Point3d>();
//Loops through iterations
for(iterations = 0; iterations < arraypts.Last; iterations++){
//Gets the closest point in the list from the first point and adds it to the used while removing it from allpts
Point3d nextpt = Rhino.Collections.Point3dList.ClosestIndexInList(arraypts, fpt);
arraypts.Remove(nextpt);
used.Add(nextpt);
}
//Output the list of the visited points
u = used;
For variable "iterations"I already right clicked and set it to integer outside the component, do I still need to do something inside the component as well?
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