- working to add virtual units to SVG parser
This commit is contained in:
parent
c3bbbc40e0
commit
c6a552d25a
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user