algorithmic modeling for Rhino
I have kind of a basic question about List Access vs. Tree access in C#(although i suppose it applies to whatever language you use). For this script I have the inputs set to List access where each list contains 4 points. What I want to do is make a list that I can add the z value of the first point from ALL the lists into one list. This is the script as it is
private void RunScript(List<Point3d> x, object y, ref object A)
List<double> heightList = new List<double>();
Point3d cenPt = pointAverage(x);
A = heightList;
the issue with this is that "heightList" gets made for each list in the input, so for 100 inputs, I get 100 heightLists with one value. I want there to be just one List that contains all the values in heightList, so that I would have one List with 100 values. I have accomplished something similar using Tree access for the inputs, but it seems like list access would be a lot simpler if I could work this out.
Kludge: flatten the C# input and use appropriate loops and list indices to access z values?
what's wrong with flattening the output? Without going the tree access route I am pretty sure this is simply what you're going to get. Also - why not just say "A = x;" and skip creating a list that's only holding one item? it should be the same result.
side note - had no idea you could treat point3ds as arrays and access their z with a ! thanks for teaching me that :D
In terms of flattening the output, can that be done inside the script?I ask because getting this list wouldn't be the end of the script. Next step would be to determine all of the possible heights in heightList (like a hashset) and group all of the 4 point lists based on which height they fall into. So for each value in the hashset of heights, there would be a list of all the groups of 4 points whose first point had that particular Z value. so say if those 4 points represented panels on a building, you would wind up with an output tree for every floor of the building.
Also, I think that's the first thing I've "taught" someone on here :P
© 2023 Created by Scott Davidson. Powered by