How can I tell if 2 pieces of geometry are the same?

How can I tell if 2 pieces of geometry (curves or lines in this instance) which are generated by different methods are the same? I’ve tried using the == and List ContainsItem nodes, but neither of them are working. See the example below. I’ve made 2 lines using the exact same start and end points, but the == node returns false, even though the data shown for each line is exactly the same.

Background:
I’m working on making a curtainwall randomization tool that removes segments from gridlines to create larger panels using the Rhythm CurtainGridLine.RemoveSegment node. All is well and good so far, except that I want to exempt some pre-selected areas from being eligible for grid segment removal (ie - ‘don’t touch the grids around THIS cw panel’). To do this, I’m creating a separate portion of my graph to select a single CW panel, get the boundaries for this panel, separate them into individual curves, then try to remove any of these curves from the list of all grid segments from the Rhythm CurtainGrid.AllSegmentCurves. I’m finding that, even though some of these curves are exactly the same, Dynamo is not recognizing them as being equal.

Additional background, I’m using a method similar to what @john_pierson discussed in an old blog post.

@djhballinger , FYI the method in the old blogpost is out of date and uses old versions of the nodes, and the maintainers of that site do not update any of the data sets. So I think you may run into a few other issues.

However, I bet you can maybe do a string comparison of the elements.

1 Like

geometric similarity and object reference equality are quite different. Are we talking about identifying if two objects are the same in memory (probably not) or are we talking about identifying if two geometric objects are the same in terms of their geometry?

One is easy, one is really hard.

lines, curves and points are doable with some guesses, you can compare them using a type of spatial hashing which is essentially what @john_pierson does above using the toString() methods on the nodes, it takes different but similar lines and converts them to a string which is the same for both. You can do this yourself by implementing a function which takes a type of geometry and converts it to some string representation where many similar geometry objects will return the same string. For example - a poly curve might map to a list of start/end points that make up the curve, rounded to the fourth decimal place all concatenated.

3 Likes

@john_pierson @Michael_Kirschner2 Michael and John - thanks for the feedback. Sounds like the object-to-string approach would probably be sufficient.

John - I noticed that the node was a little different and I was getting an error even in constructing the graph the same as the image, but I think I can get it to work anyways. Also, just cracking open dynamo and python for the Rhythm nodes gives me some ideas for how to make this work. If you have any updated resources for these things, I’d love to see them.

Thanks again!

Thanks for the feedback. I can get a youtube video going this morning demoing the workflow with the new nodes. :slight_smile: