Grasshopper

algorithmic modeling for Rhino

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

Is there a component like DUPLN from Kangaroo in GH?

Andres

Views: 1095

Replies to This Discussion

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. 

 

Attachments:

Very good script. I could easily adapt it for overlapping surfaces.

Thank you.

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 ++. :-)

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service