Having issues with trying to convert this code for finding duplicate lines with tolerance from the C# tutorial into a python script so i can develop it further to take 2 sets of lines and check duplicates in one list again the other list of lines.
This is the tutorial i have used to get this coded but having issues with the for loop conversion, starting a 32 mins in ( Geometry Gems #10: Remove Duplicate Lines) https://www.youtube.com/watch?v=NLp4st0bGUA
The rest of the code works fine if i give it a lineA, lineB input so its just the loop that’s breaking, with the error msg. “To many values to unpack”
import Rhino as rh
def RemoveDuplicates(lines,tol):
cleanedlines = [lines]
for i, in lines:
line = cleanedlines[i]
for j in reversed (lines):
other= cleanedlines[j]
dup = AreDuplicate(line,other,tol)
if (dup == True):(cleanedlines.RemoveAt(j))
return cleanlines
def AreSimilar(a,b,tol):
similar = a.DistanceTo(b) < tol
return similar
def AreDuplicate(lineA,lineB,tol):
if ((AreSimilar(lineA.From,lineB.From,tol)) and (AreSimilar(lineA.To,lineB.To,tol))or(AreSimilar(lineA.From,lineB.To,tol)) and (AreSimilar(lineA.To,lineB.From,tol))):
return True
return False
duplicates = RemoveDuplicates(lines,tol)
240412_Duplicate lines python Example WIP.gh (9.4 KB)
I know i can use, Rhino.Geomtery.GeometryBase.GeometryEquals(x,y) to find the duplicates but as this gives no tolerance option i also wanted to solve it with tolerance.
Thanks Matt