Is there in GH the equivalent as Remove Similar Lines from Kangaroo?

Is there a component like DUPLN from Kangaroo in GH?

Andres

  • up

    Andrew Heumann

    You can write a script to do it... here's a C# version. 


    private void RunScript(List<Line> L, ref object A)
    {
    List<Line> output = new List<Line>();
    output.Add(L[0]);
    for (int i = 1;i < L.Count;i++){
    bool include = true;
    for (int j = 0;j < output.Count;j++){
    if(
    output[j].PointAt(0) == L[i].PointAt(0)
    &&
    output[j].PointAt(1) == L[i].PointAt(1)
    ||
    output[j].PointAt(0) == L[i].PointAt(1)
    &&
    output[j].PointAt(1) == L[i].PointAt(0)
    ){
    include = false;
    }
    }
    if(include){
    output.Add(L[i]);
    }
    }
    A = output;
    }

     

     If you'd prefer to test within a tolerance rather than test for exact equality, you can replace the lines that look like 

    output[j].PointAt(0) == L[i].PointAt(0)

    with 

    output[j].PointAt(0).DistanceTo(L[i].PointAt(0)) < t


    I've attached a version of this script that I tend to use - it also outputs the indices of the items from the original list that remain. 

     

    1
    • up

      Andres Gonzalez

      Many thanks Andrew, I think I found a nice way to do it with GH along. My students will have a heart attack if the see C ++. :-)
      • up

        Andres Gonzalez