Problem with decimal symbol

Problem with decimal symbol

kotorotomoto
Explorer Explorer
2,273 Views
28 Replies
Message 1 of 29

Problem with decimal symbol

kotorotomoto
Explorer
Explorer

Problem with decimal symbol, maxscript crashes if a comma is set as a decimal symbol in the Windows settings, because it cannot recognize a decimal number, for example, instead of 0.3 it sees 0,3 and understands it as a sequence of numbers. The problem is not new, there is probably a simple solution without changing the regional settings of Windows

The problem looks old, but I haven't found a solution

0 Likes
2,274 Views
28 Replies
Replies (28)
Message 21 of 29

denisT.MaxDoctor
Advisor
Advisor

HOW did the "VRay Matte ShadowColour" property appear in user-defined properties?! WHO set it?!

0 Likes
Message 22 of 29

istan
Advisor
Advisor

I also struggled with the same issue in my own C++ plugins and certain versions of 3dsmax. I ended up by always adding setlocale() before I write something to an .INI, .CFG, to props,..

I can't say, if AD really fixed it (they said so at least), as I left this extra code in my plugins.

0 Likes
Message 23 of 29

denisT.MaxDoctor
Advisor
Advisor

@istan wrote:

I also struggled with the same issue in my own C++ plugins and certain versions of 3dsmax. I ended up by always adding setlocale() before I write something to an .INI, .CFG, to props,..

I can't say, if AD really fixed it (they said so at least), as I left this extra code in my plugins.


if you use MAX's built-in formatting (setINIsetting, setUserProp, coarce to string, etc.), there cannot be a comma in a string value. Not in any way, as far as I know. But if you are formatting yourself... anything can happen.

0 Likes
Message 24 of 29

denisT.MaxDoctor
Advisor
Advisor

You can change the Windows regional settings to, for example, DENMARK, where "comma" is used as a decimal separator, and reload MAX... You will see all the spinner values with locale "DE" (which uses ",").

But (setuserprop $ "val" pi) sets the property with ".", as it should be for valid expressions.

 

I haven't tested the same behavior for INI, but I expect it to be the same.

 

Maybe in some specific MAX localization (like FRENCH) the behaviour will be different, but I haven't had a chance to play with localizations other than English and Chinese.

0 Likes
Message 25 of 29

denisT.MaxDoctor
Advisor
Advisor

now that Python is available in MXS, you can see what the locale is now, set it to whatever you want, format values, and put it all back... if you're interested in doing the formatting yourself, of course. 😁

 

locale = python.import #locale
builtin = python.import #__builtin__

(locale.localeconv())["decimal_point"]

loc = locale.getlocale locale.LC_NUMERIC

locale.setlocale locale.LC_NUMERIC "de_DE"
(locale.localeconv())["decimal_point"]

builtin.unicode.format "{:n}" pi

locale.setlocale locale.LC_NUMERIC loc	

(the example code is for MAX 2020 !)

 

0 Likes
Message 26 of 29

istan
Advisor
Advisor

Yes Denis, all right.. but I had troubles in my C++ plugins. I don't remember which Max version it was, but AD fixed a bug in this area.

0 Likes
Message 27 of 29

klvnk
Collaborator
Collaborator

if you know it's a color in the range of 0-1 you could probably code something relatively robust :? 

0 Likes
Message 28 of 29

denisT.MaxDoctor
Advisor
Advisor

@klvnk wrote:

if you know it's a color in the range of 0-1 you could probably code something relatively robust :? 


🤣🤣🤣

0 Likes
Message 29 of 29

klvnk
Collaborator
Collaborator

i was thinking something like

fn str_to_p3color str =
(	
	c = [0,0,0];
	values = filterString str " [],";
	if values.count == 6 then
	(	
		c.x = ("." + values[2]) as float;
		c.x += (values[1] as float);
		
		c.y = ("." + values[4]) as float;
		c.y += (values[3] as float);
		
		c.z = ("." + values[6]) as float;
		c.z += (values[5] as float);
	)	
	c;
)

 

 

0 Likes