Hi everyone, I have an problem about the Method GetDataTree
, it could not collected data correctly. This was the first time I get the thus error, and I have check my code many time. And unfortunately I still didn’t what the problem with the Code, what’s more, when I debug the code with Visual Studio 2015 the GetDataTree
did not collect the point data. If anyone can help me, thanks
The Problem is decribe as an Gif animation. And The full Code is as an attachment at below
protected override void SolveInstance(IGH_DataAccess DA)
{
GH_Structure<GH_Point> InputPtsTree = new GH_Structure<GH_Point>();
GH_Structure<GH_Point> OutputPts = new GH_Structure<GH_Point>();
double ThreadHold = default(double);
string Sign = default(string);
int j;
int i;
double Result = 0;
GH_Path BasePath;
if(!DA.GetDataTree(0, out InputPtsTree))return;
if(!DA.GetData(1, ref ThreadHold))return;
if(!DA.GetData(2, ref Sign))return;
int TreeBranchCount = InputPtsTree.Branches.Count;
for(int Index = 0; Index < TreeBranchCount; Index++)
{
List<GH_Point> BranchsPts = InputPtsTree.Branches[Index];
BasePath = InputPtsTree.Paths[Index];
i = 0;
for (; BranchsPts.Count>0;)
{
List<GH_Point> NewBranch = new List<GH_Point>();
GH_Point i_Pt = BranchsPts[0];
NewBranch.Add(BranchsPts[0]);
BranchsPts.RemoveAt(0);
j = 0;
for(;j < BranchsPts.Count; j++)
{
GH_Point j_Pt = BranchsPts[j];
Result = Math.Abs(i_Pt.Value.DistanceTo(j_Pt.Value));
if(Result <= ThreadHold)
{
NewBranch.Add(BranchsPts[j]);
BranchsPts.RemoveAt(j);
j = j - 1;
}
}
GH_Path NewPath = BasePath.AppendElement(i);
i++;
OutputPts.AppendRange(NewBranch, NewPath);
}
}
DA.SetDataTree(0, OutputPts);
}
ClusterPts.cs (6.2 KB)