Simple question on Python operators

Hello everyone,

So, in my python script, I need to check the equality of two surface areas, for some reason, it keeps telling me they’re not equal although they are when I print the area results. I think the solution is simple but I’m still a beginner in python. I also attached both the rhino and GH files and one screenshot.

Best,

Ghadeer


Dictionary test.3dm (449.6 KB)
Dictionary test.gh (14.8 KB)

Try rounding the values returned with the area method. There may be a difference 10 decimal places in, far beyond what’s practical. If you round to 3 or 4 decimal places you may find it works.

Thank you! Now it’s working perfectly!

1 Like

Or even better use the math.isclose() function, setting your desired tolerance to avoid very close values rounding apart.

1 Like

Good to know. Thanks for that tip.

I don’t think that was added till Python 3. One could use Rhino.RhinoMath.EpsilonEquals in GHPython though, which also has equivalent methods for comparing e.g. points, vectors, and lines.

2 Likes