- fixed the Gerber parser to work for the case of having coordinates with negative values and the trailing zeros are removed and leading zeros are kept
This commit is contained in:
@@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta
|
|||||||
|
|
||||||
=================================================
|
=================================================
|
||||||
|
|
||||||
|
7.05.2021
|
||||||
|
|
||||||
|
- fixed the Gerber parser to work for the case of having coordinates with negative values and the trailing zeros are removed and leading zeros are kept
|
||||||
|
|
||||||
3.05.2021
|
3.05.2021
|
||||||
|
|
||||||
- changed the save_project() method such that when the project is saved as compressed now the compression is first done in memory and only after that the app will attempt to write it to a file on disk
|
- changed the save_project() method such that when the project is saved as compressed now the compression is first done in memory and only after that the app will attempt to write it to a file on disk
|
||||||
|
|||||||
@@ -2647,20 +2647,20 @@ def parse_gerber_number(strnumber, int_digits, frac_digits, zeros):
|
|||||||
"""
|
"""
|
||||||
Parse a single number of Gerber coordinates.
|
Parse a single number of Gerber coordinates.
|
||||||
|
|
||||||
:param strnumber: String containing a number in decimal digits
|
:param strnumber: String containing a number in decimal digits
|
||||||
from a coordinate data block, possibly with a leading sign.
|
from a coordinate data block, possibly with a leading sign.
|
||||||
:type strnumber: str
|
:type strnumber: str
|
||||||
:param int_digits: Number of digits used for the integer
|
:param int_digits: Number of digits used for the integer
|
||||||
part of the number
|
part of the number
|
||||||
:type frac_digits: int
|
:type frac_digits: int
|
||||||
:param frac_digits: Number of digits used for the fractional
|
:param frac_digits: Number of digits used for the fractional
|
||||||
part of the number
|
part of the number
|
||||||
:type frac_digits: int
|
:type frac_digits: int
|
||||||
:param zeros: If 'L', leading zeros are removed and trailing zeros are kept. Same situation for 'D' when
|
:param zeros: If 'L', leading zeros are removed and trailing zeros are kept. Same situation for 'D' when
|
||||||
no zero suppression is done. If 'T', is in reverse.
|
no zero suppression is done. If 'T', is in reverse.
|
||||||
:type zeros: str
|
:type zeros: str
|
||||||
:return: The number in floating point.
|
:return: The number in floating point.
|
||||||
:rtype: float
|
:rtype: float
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ret_val = None
|
ret_val = None
|
||||||
@@ -2670,6 +2670,19 @@ def parse_gerber_number(strnumber, int_digits, frac_digits, zeros):
|
|||||||
|
|
||||||
if zeros == 'T':
|
if zeros == 'T':
|
||||||
int_val = int(strnumber)
|
int_val = int(strnumber)
|
||||||
ret_val = (int_val * (10 ** ((int_digits + frac_digits) - len(strnumber)))) * (10 ** (-frac_digits))
|
if int_val >= 0:
|
||||||
|
ret_val = (int_val * (10 ** ((int_digits + frac_digits) - len(strnumber)))) * (10 ** (-frac_digits))
|
||||||
|
else:
|
||||||
|
# negative number therefore we have a '-' char in front of the strnumber
|
||||||
|
ret_val = (int_val * (10 ** ((int_digits + frac_digits + 1) - len(strnumber)))) * (10 ** (-frac_digits))
|
||||||
|
|
||||||
|
# if strnumber[0] == '-':
|
||||||
|
# int_val = strnumber[:(int_digits+1)]
|
||||||
|
# frac_val = strnumber[(int_digits+1):]
|
||||||
|
# else:
|
||||||
|
# int_val = strnumber[:int_digits]
|
||||||
|
# frac_val = strnumber[(int_digits):]
|
||||||
|
# ret_val = '%s.%s' % (int_val, frac_val)
|
||||||
|
# ret_val = float(ret_val)
|
||||||
|
|
||||||
return ret_val
|
return ret_val
|
||||||
|
|||||||
Reference in New Issue
Block a user