- 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
|
- fixed an error in importing SVG that has a single line
|
||||||
- updated the POT file and the PO/MO files for Turkish language
|
- updated the POT file and the PO/MO files for Turkish language
|
||||||
|
- working to add virtual units to SVG parser
|
||||||
|
|
||||||
20.09.2020
|
20.09.2020
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,21 @@ def svgparselength(lengthstr):
|
||||||
return
|
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'):
|
def path2shapely(path, object_type, res=1.0, units='MM'):
|
||||||
"""
|
"""
|
||||||
Converts an svg.path.Path into a Shapely
|
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)
|
subgeo = getsvggeo(child, object_type, root=root, units=units, res=res)
|
||||||
if subgeo is not None:
|
if subgeo is not None:
|
||||||
geo += subgeo
|
geo += subgeo
|
||||||
|
else:
|
||||||
|
factor = svgparse_viewbox(node)
|
||||||
# Parse
|
# Parse
|
||||||
elif kind == 'path':
|
if kind == 'path':
|
||||||
log.debug("***PATH***")
|
log.debug("***PATH***")
|
||||||
P = parse_path(node.get('d'))
|
P = parse_path(node.get('d'))
|
||||||
P = path2shapely(P, object_type, units=units)
|
P = path2shapely(P, object_type, units=units)
|
||||||
|
|
Loading…
Reference in New Issue