Skip to content

Commit

Permalink
When extracting, sometimes Inkscape only provides the X coordinate in…
Browse files Browse the repository at this point in the history
… translate(). Now extraction deals with that instead of halting
  • Loading branch information
saardrimer committed May 30, 2017
1 parent 37cb87e commit d335bee
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pcbmode/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,16 +638,22 @@ def parseTransform(transform):
Returns a Point() for the input transform
"""
data = {}

if transform == None:
data['type'] = 'translate'
data['location'] = Point()
elif 'translate' in transform.lower():
regex = r".*?translate\s?\(\s?(?P<x>[+-]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s?[\s,]\s?(?P<y>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s?\).*"
regex = r".*?translate\s?\(\s?(?P<x>[+-]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)(\s?[\s,]\s?)?(?P<y>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)?\s?\).*"
# regex = r".*?translate\s?\(\s?(?P<x>[+-]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s?[\s,]\s?(?P<y>[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s?\).*"
# regex = r".*?translate\s?\(\s?(?P<x>-?[0-9]*\.?[0-9]+)\s?[\s,]\s?(?P<y>-?[0-9]*\.?[0-9]+\s?)\s?\).*"
coord = re.match(regex, transform)
data['type'] = 'translate'
x = coord.group('x')
y = coord.group('y')
if coord.group('y') != None:
y = coord.group('y')
else:
y = 0
data['location'] = Point(x,y)
elif 'matrix' in transform.lower():
data['type'] = 'matrix'
Expand Down

0 comments on commit d335bee

Please sign in to comment.