GeometryBase and Equals method

I need to compare two lists of Geometrybase to know if they are equal, but I could not. Then I did this example in gh, and not is what I expected…
How do you know if two lists of geometrybase are equal?

You don’t. Equality is not defined for most Rhino SDK geometry types. It’s also not entirely clear what Equality means for many types. Are we looking for exact bit-per-bit correspondence? Are lines equal when they are within 1e-64 of each other? Are lines equal if they share the same end-points but go in opposite directions? These questions get a lot more complex when dealing with more advanced types such as PolyCurves and Breps.

What I’m trying to say is that the Equals() mechanism isn’t subtle enough for complicated types such as some GeometryBase implementations. If you tell us what sort of equality you’re looking for, then we can maybe help.

Thanks David,
I see, it is understandable. Confused me to see this method in the SDK (I lost all afternoon in this u.u).
I needed to learn how the gumball work for another project, and decided to try to implement a gumball in a gh component. The issue is this component is re-executes several times, and I need a Boolean door to see if I need to re-read the input.
That is, when I move the gumball, the component re-executes (expire), but I do not allow the input data to be read again on each iteration. But when input data changes, for example, when the user change the input source, I have to reread the input.
For this I have an internal variable that stores the input data (the first time they are read), and then in each rerunning I compare this variable with the input data. If the variable data are different of the input data, it means that the user has changed the source, and I need to make some adjustments to that case.
There are two lists of geometrybase, I do not know what geometry is.
Can you think of another way to fix it? Or the only possibility is to implement a comparison function which makes surgery to items of geometryBase lists?

Equals() is a method which is defined by System.Object, which is the base class for everything, and thus every class in .NET has Equals(). Every class also has ToString().

If the data really hasn’t changed, then you can use the static Object.ReferenceEquals() method. This method will return true if and only if the two supplied objects point to the same chunk of memory. If they are two different curves that just happen to be the same shape, this method will return false. The good thing about ReferenceEquals is that it does not care for types, and it is very very fast. The downside is that objects that have the same state but which exist separately are not recognized as being identical.

Many thanks for your help David,
maybe I’m doing something wrong or I do not know, but not works.
For example:

  Private Sub RunScript(ByVal y As Boolean, ByVal x As List(Of GeometryBase), ByRef A As Object) 

    If (Cache.count = 0) Or (y) Then
      cache = x
    End If
    print(AreEquals(x, Cache))

  End Sub 

  '<Custom additional code> 

  Public Cache As New list(Of GeometryBase)

  Public Function AreEquals(ByVal A As List(Of GeometryBase),
    ByVal B As List(Of GeometryBase)) As Boolean
    If (A.Count <> B.Count) Then
      Return False
      Exit Function
    End If
    For i As Int32 = 0 To A.Count - 1
      If Not (Object.ReferenceEquals(A(i), B(i))) Then
        Return False
        Exit Function
      End If
    Return True
  End Function

  '</Custom additional code> 
End Class
<a class="attachment" href=""></a> (6.3 KB)