[Bf-committers] Numeric fields should accept coma and convert it todot

Campbell Barton ideasman42 at gmail.com
Sun Apr 17 08:00:53 CEST 2011


recommend to look at interface.c and bpy_interface.c -
BPY_button_exec(), in principle what you suggest could work however
all parsing is done by python its not so simple to make decisions
based on input unless we write our own.

In brief it works like this:
* user inputs some number/py-code/units
* for unit buttons blender does python compatible replacements (yes,
units systems cheats by relying on python :-) ).
* python evaluates this string - if its a tuple ist sum'd, otherwise a
number is expected.

The conflict with units is input from multiple units system is
possible, so you can type in 10cm even if Imperial units are selected.
Or 10' when Metric is used.

On Sat, Apr 16, 2011 at 10:24 PM, Damir Prebeg <blend.factory at gmail.com> wrote:
> Well, I know that Python interprets 1, 2 as (1, 2) but as I can see
> numeric field actually calculates sum of numbers separated by coma
> witch Python doesn't do by it self. Since parser does that, wouldn't
> be possible to create parser that will distinguish simple 1, 2 from
> sum(1, 2) or from [1, 2]?
> And to be honest, I don't understand what's the problem with units. If
> someone uses imperial, metric or blender unit system, then he will use
> only one system at the time. Parser should be aware active unit system
> and should not mix 1'000,00 and 1,0.
>
> On 16 April 2011 16:12, Campbell Barton <ideasman42 at gmail.com> wrote:
>> Also units, where: 2' 4"
>> ... is valid input for: 2 ft 4 inches
>>
>> Supporting 1'000,00 & units & python evaluation would be tricky and
>> error prone enough to make it not workable IMHO.
>>
>> On Sat, Apr 16, 2011 at 11:28 AM, Martin Poirier <theeth at yahoo.com> wrote:
>>> The issue is that it doesn't accept just numbers, it accepts anything that evaluates to an expression, so you can type stuff lie: 1/3, 16/9*480, sum(15, 12.5, 48.6), ...
>>>
>>> Strictly parsing with a locale is not possible.
>>>
>>> Martin
>>>
>>> --- On Sat, 4/16/11, Remo Pini <remo.pini at avexys.com> wrote:
>>>
>>>> From: Remo Pini <remo.pini at avexys.com>
>>>> Subject: Re: [Bf-committers] Numeric fields should accept coma and convert it todot
>>>> To: "bf-blender developers" <bf-committers at blender.org>
>>>> Received: Saturday, April 16, 2011, 3:54 AM
>>>> I actually think that Blender should
>>>> try to adhere to whatever locale
>>>> settings the user has chosen if at all possible. This goes
>>>> for date,
>>>> time and number formats.
>>>>
>>>> I've seen numbers setup like 1000.00 / 1'000.00 / 1,000.00
>>>> / 1'000,00 ->
>>>> simply accepting "." and "," will not solve this issues,
>>>> the "parser"
>>>> needs to be locale aware instead of just replacing
>>>> things...
>>>>
>>>> Cheers
>>>>
>>>> Remo
>>>>
>>>> > -----Original Message-----
>>>> > From: bf-committers-bounces at blender.org
>>>> [mailto:bf-committers-
>>>> > bounces at blender.org]
>>>> On Behalf Of Damir Prebeg
>>>> > Sent: Freitag, 15. April 2011 11:08
>>>> > To: bf-blender developers
>>>> > Subject: [Bf-committers] Numeric fields should accept
>>>> coma and convert
>>>> it
>>>> > todot
>>>> >
>>>> > I use numeric keys a lot, but on my locale settings
>>>> num key DEL is
>>>> > coma not dot. Because of that I often make mistakes
>>>> with numeric
>>>> > inputs. I think that all numeric fields should accept
>>>> and convert coma
>>>> > to dot.
>>>> > _______________________________________________
>>>> > Bf-committers mailing list
>>>> > Bf-committers at blender.org
>>>> > http://lists.blender.org/mailman/listinfo/bf-committers
>>>> _______________________________________________
>>>> Bf-committers mailing list
>>>> Bf-committers at blender.org
>>>> http://lists.blender.org/mailman/listinfo/bf-committers
>>>>
>>> _______________________________________________
>>> Bf-committers mailing list
>>> Bf-committers at blender.org
>>> http://lists.blender.org/mailman/listinfo/bf-committers
>>>
>>
>>
>>
>> --
>> - Campbell
>> _______________________________________________
>> Bf-committers mailing list
>> Bf-committers at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-committers
>>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>



-- 
- Campbell


More information about the Bf-committers mailing list