Eliminate duplicate curves (including reversed)?

I am putting adaptive components on the edges of curtain panels. The problem is that the curves are redundant (but reversed) where two panels meet.

How to filter a list of curves for unique items if the curves’ direction may be reversed?

This doesn’t work…

2 Likes

Duplicate Item Indices is from archi-lab

That is absolutely brilliant.

>Duplicate Item Indices is from archi-lab

I’m not seeing Duplicate Item Indices except for an old 2014 package with the name “Duplicate Item Indices”. I pasted the Python code from https://gist.github.com/ksobon/8b6a2a5d972456d6d797 and that worked.

There is something not really working with archi-lab and yesterday’s Dynamo build. I don’t see its nodes listing in Dynamo’s Library.

There should be a lot more nodes in the package. Maybe try downloading one of the older ones. It is a very helpful package. I think its from the same creator of Bumbelbee

A really simple, but clever workaround is filtering all the curves, based on their lengths. Usually, Dynamo shows lengts with precision down to the 12th number after the decimal, so it’s practically impossible to have identical lengths for non - identical curves. I have recently had problems with those archi - lab nodes as well, as they seem to be problematic in terms of using with the generative design tool. So I used a really simple python script to create a bool mask, based on the lengths. Check this out:

Here’s the Python code:

Wouldn’t there be many identical lengths on a curtainwall’s panel edges?

There’s Prune duplicates from Data-Shapes, which operates with geometry.

you are right, I didn’t go into too much detail about your trouble. I meant it as a general approach towards filtering duplicating curves, but in your case perhaps archi-lab and data-shapes nodes would do a better job :slight_smile:

What do you think about this solution with using OOTB nodes only?

3 Likes

Clever and succinct.

Anyone know why I got -1?

Hello @vanman …could it help with all indicies of instead of list index of…

1 Like

Looks good but ill need the difference of a list of lines before

List.IndexOf (and so on) becomes slow with large lists.
Try this:

1 Like

Thanks Vladimir! Dictionary seems like a great idea. I cant use orchard at my firm. To many issues with deploying it and other scripts. Is there another node instead of object.hashing I can use? Ill do a little research now. I havnt used dictionary’s at all yet

@vanman , try this (replace hashing). But speed may decrease vs Hashing.

I have a go-to piece of Python that uses the String representation of the Curve/Line (both in its normal direction and reversed) for the purpose of cleaning a list of Curves/Lines.

Here is the code just in case you want to try it. :wink:

import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

## For removing duplicate Curves
def cleanLines(curves):
	C0 = []
	C1 = []
	for c in curves:
		if str(c) not in C1 and str(Line.Reverse(c)) not in C1:
			C0.append(c)
			C1.append(str(c))
	return C0
	
OUT = cleanLines(IN[0])

2 Likes

Thanks Ewan, your to good to me :joy:

Been trying to make topos from TINs more efficiently. The over lapping triangle surfaces you have to explode become an issue. Your script does well to reduce the lines. Interestingly removing same curve lengths reduces it more. I wonder if its doing some rounding, or there are curves that end up the same length or I’ve got something wrong.

1 Like