Skip to content

Commit 15d23f5

Browse files
author
Juergen Weigert
committed
v0.20 better honor display:none, visibility:hidden.
1 parent 1d37b23 commit 15d23f5

3 files changed

Lines changed: 20 additions & 14 deletions

File tree

paths2openscad-de.inx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ umgerechnet: 96 px = 1 inch = 25.4 mm.
117117
(Vor inkscape 0.92 war der Standard 90 px pro inch,
118118
Adobe Produkte verwenden oft 75 px pro inch)
119119

120-
v0.19
120+
v0.20
121121
Dan Newman (dan newman @ mtbaldy us)
122122
Josef Skladanka (jskladan @ redhat com)
123123
Juergen Weigert (juergen @ fabmail org)

paths2openscad.inx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ definition of 96 px = 1 inch = 25.4 mm.
117117
(Before inkscape 0.92 the standard was 90 px per inch,
118118
Adobe products often use 75 px per inch)
119119

120-
v0.19
120+
v0.20
121121
Dan Newman (dan newman @ mtbaldy us)
122122
Josef Skladanka (jskladan @ redhat com)
123123
Juergen Weigert (juergen @ fabmail org)

paths2openscad.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
2-
3-
# openscad.py
4-
2+
#
3+
# paths2openscad.py
4+
#
55
# This is an Inkscape extension to output paths to extruded OpenSCAD polygons
66
# The Inkscape objects must first be converted to paths (Path > Object to
77
# Path). Some paths may not work well -- the paths have to be polygons. As
@@ -62,6 +62,10 @@
6262
# 2017-08-10, juergen@fabmail.org
6363
# 0.19 fix style="" elements.
6464
#
65+
# 2017-11-14, juergen@fabmail.org
66+
# 0.20 do not traverse into objects with style="display:none"
67+
# some precondition checks had 'pass' but should have 'continue'.
68+
#
6569
# CAUTION: keep the version numnber in sync with paths2openscad.inx about page
6670

6771
# This program is free software; you can redistribute it and/or modify
@@ -880,7 +884,11 @@ def recursivelyTraverseSvg(self, aNodeList, matCurrent=[[1.0, 0.0, 0.0], [0.0, 1
880884
if v == 'inherit':
881885
v = parent_visibility
882886
if v == 'hidden' or v == 'collapse':
883-
pass
887+
continue
888+
889+
s = node.get('style', '')
890+
if s == 'display:none':
891+
continue
884892

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

910918
refid = node.get(inkex.addNS('href', 'xlink'))
911919
if not refid:
912-
pass
920+
continue
913921

914922
# [1:] to ignore leading '#' in reference
915923
path = '//*[@id="%s"]' % refid[1:]
@@ -948,7 +956,7 @@ def recursivelyTraverseSvg(self, aNodeList, matCurrent=[[1.0, 0.0, 0.0], [0.0, 1
948956
x = float(node.get('x'))
949957
y = float(node.get('y'))
950958
if (not x) or (not y):
951-
pass
959+
continue
952960
w = float(node.get('width', '0'))
953961
h = float(node.get('height', '0'))
954962
a = []
@@ -974,7 +982,7 @@ def recursivelyTraverseSvg(self, aNodeList, matCurrent=[[1.0, 0.0, 0.0], [0.0, 1
974982
x2 = float(node.get('x2'))
975983
y2 = float(node.get('y2'))
976984
if (not x1) or (not y1) or (not x2) or (not y2):
977-
pass
985+
continue
978986
a = []
979987
a.append(['M ', [x1, y1]])
980988
a.append([' L ', [x2, y2]])
@@ -994,7 +1002,7 @@ def recursivelyTraverseSvg(self, aNodeList, matCurrent=[[1.0, 0.0, 0.0], [0.0, 1
9941002

9951003
pl = node.get('points', '').strip()
9961004
if pl == '':
997-
pass
1005+
continue
9981006

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

10151023
pl = node.get('points', '').strip()
10161024
if pl == '':
1017-
pass
1025+
continue
10181026

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

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

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

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

0 commit comments

Comments
 (0)