3838"""
3939
4040class Line (object ):
41- def __init__ (self , height = "featureHeight" , width = "0.5" , base = False , wall = False , insideWall = False ):
41+ def __init__ (self , height = "featureHeight" , width = "0.5" , base = False , wall = False , insideWall = False , stroke = False ):
4242 self .height = height
4343 self .width = width
4444 self .base = base
4545 self .wall = wall
4646 self .insideWall = insideWall
47+ self .stroke = stroke
4748 self .points = []
4849
4950 def toCode (self , pathCount ):
5051 code = []
5152 path = 'path' + str (pathCount )
5253 code .append ( path + '=scale*[' + ',' .join (('[%.3f,%.3f]' % tuple (p ) for p in self .points )) + '];' );
53- if not self .base :
54+ if self .stroke :
5455 code .append ('render(convexity=10) linear_extrude(height=(' + self .height + ')) ribbon(' + path + ',thickness=' + self .width + ');' )
5556 if self .wall :
5657 baseRibbon = 'render(convexity=10) linear_extrude(height=wallFlareThickness) ribbon(' + path + ',thickness=wallFlareWidth);'
@@ -64,7 +65,7 @@ def toCode(self, pathCount):
6465 code .append (' ' + baseRibbon );
6566 code .append (' translate([0,0,-0.01]) linear_extrude(height=insideWallFlareThickness+0.02) polygon(points=' + path + ');' )
6667 code .append ('}' )
67- else :
68+ if self . base :
6869 code .append ('render(convexity=10) linear_extrude(height=connectorThickness) polygon(points=' + path + ');' )
6970 return code
7071
@@ -84,10 +85,14 @@ def svgToCookieCutter(filename, tolerance=0.1, strokeAll = False):
8485 for path in superpath .breakup ():
8586 line = Line ()
8687
88+ line .base = False
89+ line .stroke = False
90+
8791 if path .svgState .fill is not None :
8892 line .base = True
89- elif strokeAll or path .svgState .stroke is not None :
90- line .base = False
93+
94+ if strokeAll or path .svgState .stroke is not None :
95+ line .stroke = True
9196 if isRed (path .svgState .stroke ):
9297 line .width = "min(maxWallWidth,max(%.3f,minWallWidth))" % path .svgState .strokeWidth
9398 line .height = "wallHeight"
@@ -100,7 +105,7 @@ def svgToCookieCutter(filename, tolerance=0.1, strokeAll = False):
100105 line .width = "min(maxFeatureThickness,max(%.3f,minFeatureThickness))" % path .svgState .strokeWidth
101106 line .height = "featureHeight"
102107 line .wall = False
103- else :
108+ elif not line . base :
104109 continue
105110
106111 lines = path .linearApproximation (error = tolerance )
0 commit comments