- working to add virtual units to SVG parser

This commit is contained in:
Marius Stanciu 2020-09-22 17:47:23 +03:00
parent c3bbbc40e0
commit c6a552d25a
2 changed files with 67 additions and 50 deletions

View File

@ -11,6 +11,7 @@ CHANGELOG for FlatCAM beta
- fixed an error in importing SVG that has a single line
- updated the POT file and the PO/MO files for Turkish language
- working to add virtual units to SVG parser
20.09.2020

View File

@ -58,6 +58,21 @@ def svgparselength(lengthstr):
return
def svgparse_viewbox(root):
val = root.get('viewBox')
if val is None:
return 1.0
res = [float(x) for x in val.split()] or [float(x) for x in val.split(',')]
w = svgparselength(root.get('width'))[0]
# h = svgparselength(root.get('height'))[0]
v_w = res[2]
# v_h = res[3]
return w / v_w
def path2shapely(path, object_type, res=1.0, units='MM'):
"""
Converts an svg.path.Path into a Shapely
@ -369,9 +384,10 @@ def getsvggeo(node, object_type, root=None, units='MM', res=64):
subgeo = getsvggeo(child, object_type, root=root, units=units, res=res)
if subgeo is not None:
geo += subgeo
else:
factor = svgparse_viewbox(node)
# Parse
elif kind == 'path':
if kind == 'path':
log.debug("***PATH***")
P = parse_path(node.get('d'))
P = path2shapely(P, object_type, units=units)