algorithmic modeling for Rhino
Tags:
DataTree<int> tree = new DataTree<int>();
int interim = 0;
for(int i = 0; i < p; i++)
{
GH_Path path = new GH_Path(i); //creates a first-level path
for(int j = 0; j < n; j++)
{
tree.Add(interim, path); //add current number to path
interim++;
}
}
A = tree;
private void RunScript(DataTree val, ref object A)
{
DataTree meanTree = new DataTree();
for (int i = 0; i < val.BranchCount; i++)
{
GH_Path path = val.Path(i); //path for this index
int elementCount = val.Branch(i).Count; //count of element in this index
List item = val.Branch(path);
int itnum = item.Count; //number of items
for(int j = 0; j < itnum; j++)
{
double itpart = item[j];
int k = 0;
if (double sum <= 0) //problem here trying to define the variable sum
{
double sum = val[path, 0];
}
do
{
double sum = sum + itpart;
k++;
} while (k < itnum);
}
meanTree.Add(i, path);
}
A = meanTree;
}
private void RunScript(List val, ref object A)
{
int i = 0;
double sum = 0;
do
{
sum = sum + val[i];
i++;
} while(i < val.Count);
double mean = sum / val.Count;
A = mean;
}
private void RunScript(DataTree<double> tree, ref object A)
{
DataTree<double> results = new DataTree<double>();
for(int i = 0; i < tree.BranchCount; i++)
{
GH_Path path = tree.Path(i);
List<double> branch = tree.Branch(i);
double sum = 0.0;
if(branch != null && branch.Count > 0)
{
for(int j = 0; j < branch.Count; j++)
{
sum += branch[j];
}
sum /= branch.Count;
}
results.Add(sum, path);
}
A = results;
}
Added by Naoto Tamura 0 Comments 0 Likes
Added by Naoto Tamura 3 Comments 1 Like
© 2018 Created by Scott Davidson. Powered by