Skip to content

Commit

Permalink
v0.20 better honor display:none, visibility:hidden.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnweiger committed Nov 15, 2017
1 parent 1d37b23 commit 15d23f5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
2 changes: 1 addition & 1 deletion paths2openscad-de.inx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ umgerechnet: 96 px = 1 inch = 25.4 mm.
(Vor inkscape 0.92 war der Standard 90 px pro inch,
Adobe Produkte verwenden oft 75 px pro inch)

v0.19
v0.20
Dan Newman (dan newman @ mtbaldy us)
Josef Skladanka (jskladan @ redhat com)
Juergen Weigert (juergen @ fabmail org)
Expand Down
2 changes: 1 addition & 1 deletion paths2openscad.inx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ definition of 96 px = 1 inch = 25.4 mm.
(Before inkscape 0.92 the standard was 90 px per inch,
Adobe products often use 75 px per inch)

v0.19
v0.20
Dan Newman (dan newman @ mtbaldy us)
Josef Skladanka (jskladan @ redhat com)
Juergen Weigert (juergen @ fabmail org)
Expand Down
30 changes: 18 additions & 12 deletions paths2openscad.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python

# openscad.py

#
# paths2openscad.py
#
# This is an Inkscape extension to output paths to extruded OpenSCAD polygons
# The Inkscape objects must first be converted to paths (Path > Object to
# Path). Some paths may not work well -- the paths have to be polygons. As
Expand Down Expand Up @@ -62,6 +62,10 @@
# 2017-08-10, juergen@fabmail.org
# 0.19 fix style="" elements.
#
# 2017-11-14, juergen@fabmail.org
# 0.20 do not traverse into objects with style="display:none"
# some precondition checks had 'pass' but should have 'continue'.
#
# CAUTION: keep the version numnber in sync with paths2openscad.inx about page

# This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -880,7 +884,11 @@ def recursivelyTraverseSvg(self, aNodeList, matCurrent=[[1.0, 0.0, 0.0], [0.0, 1
if v == 'inherit':
v = parent_visibility
if v == 'hidden' or v == 'collapse':
pass
continue

s = node.get('style', '')
if s == 'display:none':
continue

# First apply the current matrix transform to this node's tranform
matNew = simpletransform.composeTransform(
Expand Down Expand Up @@ -909,7 +917,7 @@ def recursivelyTraverseSvg(self, aNodeList, matCurrent=[[1.0, 0.0, 0.0], [0.0, 1

refid = node.get(inkex.addNS('href', 'xlink'))
if not refid:
pass
continue

# [1:] to ignore leading '#' in reference
path = '//*[@id="%s"]' % refid[1:]
Expand Down Expand Up @@ -948,7 +956,7 @@ def recursivelyTraverseSvg(self, aNodeList, matCurrent=[[1.0, 0.0, 0.0], [0.0, 1
x = float(node.get('x'))
y = float(node.get('y'))
if (not x) or (not y):
pass
continue
w = float(node.get('width', '0'))
h = float(node.get('height', '0'))
a = []
Expand All @@ -974,7 +982,7 @@ def recursivelyTraverseSvg(self, aNodeList, matCurrent=[[1.0, 0.0, 0.0], [0.0, 1
x2 = float(node.get('x2'))
y2 = float(node.get('y2'))
if (not x1) or (not y1) or (not x2) or (not y2):
pass
continue
a = []
a.append(['M ', [x1, y1]])
a.append([' L ', [x2, y2]])
Expand All @@ -994,7 +1002,7 @@ def recursivelyTraverseSvg(self, aNodeList, matCurrent=[[1.0, 0.0, 0.0], [0.0, 1

pl = node.get('points', '').strip()
if pl == '':
pass
continue

pa = pl.split()
d = "".join(["M " + pa[i] if i == 0 else " L " + pa[i] for i in range(0, len(pa))])
Expand All @@ -1014,7 +1022,7 @@ def recursivelyTraverseSvg(self, aNodeList, matCurrent=[[1.0, 0.0, 0.0], [0.0, 1

pl = node.get('points', '').strip()
if pl == '':
pass
continue

pa = pl.split()
d = "".join(["M " + pa[i] if i == 0 else " L " + pa[i] for i in range(0, len(pa))])
Expand Down Expand Up @@ -1048,7 +1056,7 @@ def recursivelyTraverseSvg(self, aNodeList, matCurrent=[[1.0, 0.0, 0.0], [0.0, 1
rx = float(node.get('r', '0'))
ry = rx
if rx == 0 or ry == 0:
pass
continue

cx = float(node.get('cx', '0'))
cy = float(node.get('cy', '0'))
Expand Down Expand Up @@ -1089,7 +1097,6 @@ def recursivelyTraverseSvg(self, aNodeList, matCurrent=[[1.0, 0.0, 0.0], [0.0, 1
plaintext = "', '".join(texts).encode('latin-1')
inkex.errormsg('Warning: text "%s"' % plaintext)
inkex.errormsg('Warning: unable to draw text, please convert it to a path first.')
pass

elif node.tag == inkex.addNS('title', 'svg') or node.tag == 'title':
pass
Expand All @@ -1102,7 +1109,6 @@ def recursivelyTraverseSvg(self, aNodeList, matCurrent=[[1.0, 0.0, 0.0], [0.0, 1
'Consider using the "Trace bitmap..." tool of the "Path" menu. Mac users please '
'note that some X11 settings may cause cut-and-paste operations to paste in bitmap copies.'))
self.warnings['image'] = 1
pass

elif node.tag == inkex.addNS('pattern', 'svg') or node.tag == 'pattern':
pass
Expand Down

0 comments on commit 15d23f5

Please sign in to comment.