V6 Bug: coerce3dpoint

Really? Hmm, maybe it’s the comma/period thing, I’m on a US English OS… what if you do this?

line = r"-1.00000000 0.00000000 0.00000000 0.00000000 1.00000000 0.00000000"

i.e. use a raw string?

Still failure with the raw string. Maybe someone else with German OS can check @clement ?
I mean it works in V5, so something is broken…
Thanks, Jess

Does it work better with decimal comma instead?

line = "-1,000000 0,000000 0,000000 0,000000 1.000000 0,000000"

?

1 Like

Hi Nathan,
with comma as a separator it works in V6 - but then V5 returns None. The tool I’m working on should work on both versions. Looks like the localizing problems are back in V6 :frowning:

Hmm, I tried here on a French/Swiss OS, and it seemed to work with Rhino in either French or English. However, I noticed the machine was still set to decimal point as separator - I guess that’s standard for CH…

I changed it to comma, rebooted the machine, but that didn’t seem to make any difference either though.

Edit: @jess - what if you run rs.LocaleID(1033) at the top of your script? Does that change anything?

1 Like

rs.LocaleID() just returns the currently used interface language. You cannot set that. Also it would not change the python behavior.

Looks like __host.Coerce3dPointFromEnumerables(point) is causing the problem.
However, if I use float() for each element of my strings it works.

I don’t want to get into that localization nightmare again… However, everyone converting strings to points or vectors should be aware of the current behavior of V6.

Thanks for all the help!
Jess

Oh, yeah, sorry, I got that wrong, just remembering from my vb days, it was SetLocale(xxxx) which was able to set the locale during script execution - but it was not a Rhinoscript function, it was a native vbscript method.

There is this:
https://docs.python.org/2/library/locale.html
No idea if it works though.

That sounds weird since coerce3dpoint already uses float() on the elements of the enumerable.

Do you have Rhino interface language also set to German?

NO! That’s another nightmare for me :wink:

What does print(values) output?

[’-1.00000000’, ‘0.00000000’, ‘0.00000000’, ‘0.00000000’, ‘1.00000000’, ‘0.00000000’]

I just tested and can confirm. I added RH-45112.
It will be fixed in the next SR – I need to confirm which one is “next”, if 3 or 4.

1 Like

@Jess

This sample works. Can you just check that it works also for you?

import rhinoscriptsyntax as rs

import System as s
ic = s.Globalization.CultureInfo.InvariantCulture
cc = s.Threading.Thread.CurrentThread.CurrentCulture
s.Threading.Thread.CurrentThread.CurrentCulture = ic

line = "-1.00000000 0.00000000 0.00000000"
list_line = line.split()
pt = rs.coerce3dpoint(list_line)
print pt
print type(pt)

s.Threading.Thread.CurrentThread.CurrentCulture = cc
1 Like

@piac that works fine.
Thanks!

1 Like

@Jess, sorry for beeing late. I see the same as you do, works in V5 fails in V6 using sauerkraut OS. This seems to be a workaround for now:

list_line = map(float, line.replace(",",".").split())

These where funny times, i still remember some of the example scripts.

_
c.

1 Like

Hi @piac, i still see it fail in V6 using this input with commas instead of dots:

line = "-1,00000000 0,00000000 0,00000000"

gives me this:

-100000000,0,0

_
c.

@clement It’s not failing if you change commas (",") to dots ("."). The invariant culture uses commas as graphic separators, and dots as decimals separators.

https://msdn.microsoft.com/en-us/library/system.globalization.numberformatinfo.invariantinfo.aspx

Which is what I’d expect.
Why? Because in Rhino there is no comma as decimal-separator. No matter which local settings the computer uses - the internal calculations are always with dot as the separator.
Of course you’ll have to format your input string accordingly…

Hi @piac, yes with dots your example works fine.

_
c.

RH-45112 is fixed in the latest Service Release Candidate