Filtering a List by another List

Hey guys I’m sure this is a repetitive question but I am getting frustrated as it’s very simple but doesn’t work. Would you plz have a look at the attached screenshot and let me know why I get False answer while the item is obviously included in the List. Thanks

Hi, you cant use equality with points (as points), but you can use equality using X, Y Z coordinates of points.

Something like this:

List of Points X == PT X &&
List of Points Y == PT Y &&
List of Points Z == PT Z

Also to avoid further errors use Math.Round to some precision.

1 Like

why not use the builtin OOTB node?
image
You are dealing with geometry hence this would be most suitable for you

3 Likes

or you could use a dash of python

2 Likes

You could use the node, “allindicesof” to get the correct index.

2 Likes

Another common issue you encounter when comparing geometries is rounding or precision. Precision between Revit and Dynamo differs and can result in slightly misleading values. Sometimes these values get rounded and look the same but mathematically are not. To avoid dealing with rounding discrepancies you can convert the geometry to strings and compare the string values as they will usually be the same.

2 Likes

You can also use the method Geometry.DistanceTo()
example
OUT = [x for x in IN[0] if x.DistanceTo(IN[1]) < 0.01]

2 Likes

In design script: Geometry.DistanceTo(PntLst, Pnt)<= Tolerance;

Converting the points to strings with two String.FromObject would also allow for an equality test and might be faster than a geometry comparison.

2 Likes

Thanks everyone. All comments were kind of helpful but I simply fixed the issue by changing geometry to string. using node “string from object” node. @stillgotme Geometry.isalmostEqualTo is also a quick solution. Thanks.
@HalfBaked Thanks buddy but I am still a beginner in using Python so couldn’t try your idea. Thanks a lot. Thanks @Daan but didn’t get how that node is helpful in this case. Thanks @Nick_Boyts That was a good point to bear in mind. Thanks guys @JacobSmall @c.poupin

2 Likes

Hi everyone, Thanks again for your help. Just to share the result of the idea I’ve been working on please have a look at the image below. The idea was to create a Dynamo graph which can develop the cable trench model in Revit using a set of setout points. Still needs more work but there are many other usage of this idea like modeling Channels.

2 Likes