Python GetPointCoordinates anomaly

I am running a small script to get point coordinates to add to another script.

import rhinoscriptsyntax as rs

points = rs.GetPointCoordinates(message="Select Points", preselect=False)
for point in points: print point

I create a profile curve by projecting a line onto my template shape. I then put points at each 90º “corner” that I want to get coordinates from. All points should be 0 in the Y-axis. This is what I am getting in my command history.

Here is a shot of my 4 viewports …

I am just printing coordinates for now, then copying into Atom to use as a dict list like this …

pointList1 = [(0,0,0), (-3.6,0,0), (-3.6,0,1.2), (-2.4,0,1.2), (-2.4,0,3.8), (-6,0,3.8), (-6,0,5.5), (-5.3,0,5.5), (-5.3,0,4.5), (0,0,4.5)]

pointList2 = [(0,0,0), (-3.6,0,0), (-3.6,0,1.2), (-2.4,0,1.2), (-2.4,0,3.8), (-6,0,3.8), (-6,0,5.5), (0,0,5.5)]

pointList3 = [(0,0,0), (-3.6,0,0), (-3.6,0,1.2), (-2.4,0,1.2), (-2.4,0,3.8), (-6,0,3.8), (-6,0,5.5), (-5.5,0,5.5), (-5.5,0,4.5), (0,0,4.5)]

Any ideas why I am not getting 0 for my Y coordinates?

Thanks, «Randy

Actually, you are getting essentially zero values. 4E-16 is a very small number. Due to how floating points work, especially through python, you’ll see small fluctuations. The best thing to do is to push those numbers through a filter with elipson check: if the absolute value of something is smaller than i.e. 1E-5 you’d set it manually to 0.0

edit: Read up on for some potentially mind-boggling number arithmetic precision problems and conversion awkwardness.

edit2: add some examples

def zero(val):
     if abs(val)<1e-5: return 0.0
     else: return val

zero(4.1e-16) # 0.0
zero(10.0) # 10

def float_equal(v1, v2):
    if(abs(v1-v2)<1e-5): return True
    return False

float_equal(4.1e-16, 4.2e-16) # True
float_equal(4.1, 4.2) # False

edit3: the comparison function I presented (which I often use) is apparently not the best way, although for my use cases it suffices. But here some more interesting to read:


Hi Nathan, thanks . I have seen these numbers ending with E-something and was never sure what it meant.

So for my purposes, I could just use your zero function.


Yes, but maybe zero() is a bit of a bad name in the long term. Maybe instead call it float_clean_threshold() or something. Or in the very least add a clear docstring to the function if you keep the zero() name :).


That’s called scientific notation.

Thanks @MarcusStrube , the bad side of being an artist.

Tschüß, «Randy

Hi Randy, a lot of people really say ‘tschüss’ in Hamburg. But it’s derived from a French word after Napoleon’s soldiers left. (adieu → adjüs → atschüs → tschüss). Ciao, Marcus

Hi Marcus, when i was taking a German course back in the early 90’s my teacher said I spoke like I was from Hamburg. She was from Stuttgart, and I knew a little Dutch from travelling there visiting friends of my parents. is Crime Scene Cleaner (Der Tatortreiniger) from the north? I love that show! Caio, Randy

That’s very good. It’s like being a native speaker and someone says, you sound like you are from London. So, it’s like the best thing that can happen to you out here. :joy:

Wow, I didn’t know that can be bought subtitled in the US. Yes, he was born in Hamburg and he is indeed very nordic.

1 Like

Hi, @rhinorudi! There are 3 new episodes for christmas. Maybe you can watch them from the US as well.

Guten Abend @MarcusStrube thanks for the head’s up. I will look out for them. I have a couple of episodes from season 5 and I have the German transcripts. I need the subtitles because my German is so rusty. Frohe Weihnachten!

Ja, frohe Weihnachten… Public-law TV often has subtitles for deaf people though.

1 Like