V6 Bug: coerce3dpoint

python
rhinocommon-v6

#1

Hi, this fails in Rhino V6 SR3,
worked fine in V5

import string
import rhinoscriptsyntax as rs

line = "-1.00000000 0.00000000 0.00000000 0.00000000 1.00000000 0.00000000"
list_line = string.split(line)
pt = rs.coerce3dpoint(list_line[0:3])
vt = rs.coerce3dvector(list_line[3:])
print pt,vt

-100000000,0,0 0,100000000,0


#2

Hi Jess,

This seems to be working here:

import rhinoscriptsyntax as rs

line = "-1.00000000 0.00000000 0.00000000 0.00000000 1.00000000 0.00000000"
list_line = line.split()
pt = rs.coerce3dpoint(list_line[0:3])
vt = rs.coerce3dvector(list_line[3:])
print pt,vt
print type(pt), type(vt)

>>>-1,0,0 0,1,0
>>><type 'Point3d'> <type 'Vector3d'>

#3

Hi Mitch,
Thanks for checking. I also get Point3d and Vector3d types. Strange…
I’ll have to use float() for each element until this is fixed.


#4

I guess I don’t understand what is not working…


#5

instead of 1.0 and -1.0
I get 100 Millions :confused:


#6

Yeah, I saw that, but in my example not. I think importing the string module is not a good idea, not necessary and it is also deprecated as far as I know…

https://docs.python.org/2/library/string.html#deprecated-string-functions

???

–Mitch


#7

OK, thanks for the hint! I’ve stripped off the string import.
Anyways it still fails.


#8

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?


#9

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


(Nathan 'jesterKing' Letwory) #10

Does it work better with decimal comma instead?

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

?


#11

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:


#12

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?


#13

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


#14

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.


(Nathan 'jesterKing' Letwory) #15

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

Do you have Rhino interface language also set to German?


#16

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


(Nathan 'jesterKing' Letwory) #17

What does print(values) output?


#18

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


(Giulio Piacentino) #19

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.


(Giulio Piacentino) #20

@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