Skip to content

Commit b300581

Browse files
committed
fix invert, add back auto mask support
1 parent a02c9bb commit b300581

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

inkscape/svg2shenzhen/export.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,30 +293,34 @@ def setDocumentSquare(self):
293293
root.attrib['width'] = str(height) + "mm"
294294
root.attrib['viewBox'] = "0 0 %f %f" % (height, height)
295295

296-
def findLayer(self, layerName):
296+
def findLayer(self, layerName, contains=False):
297297
svg_layers = self.document.xpath('//svg:g[@inkscape:groupmode="layer"]', namespaces=inkex.NSS)
298298
for layer in svg_layers:
299299
label_attrib_name = "{%s}label" % layer.nsmap['inkscape']
300300
if label_attrib_name not in layer.attrib:
301301
continue
302-
if (layer.attrib[label_attrib_name] == layerName):
302+
if ((layer.attrib[label_attrib_name] == layerName) and (contains == False)):
303303
return layer
304+
elif ((layerName in layer.attrib[label_attrib_name]) and (contains == True)):
305+
return layer
306+
304307
return False
305308

306309
def effect(self):
307310
# self.setDocumentSquare()
308311
self.setInkscapeScaling()
309-
self.processLayerSetting()
312+
self.processAutoMasks()
310313
self.processExportLayer()
311314
if (self.options.openfactory):
312315
webbrowser.open("https://www.pcbway.com/setinvite.aspx?inviteid=54747", new = 2)
313316

314-
def processLayerSetting(self):
315-
self.processMaskAuto()
317+
def processAutoMasks(self):
318+
self.processAutoMaskFromTo("F.Cu", "F.Mask-auto")
319+
self.processAutoMaskFromTo("B.Cu", "B.Mask-auto")
316320

317-
def processMaskAuto(self):
318-
copper_layer = self.findLayer("F.Cu")
319-
cpmask_layer = self.findLayer("F.Mask-auto")
321+
def processAutoMaskFromTo(self, from_layer, to_layer):
322+
copper_layer = self.findLayer(from_layer, False)
323+
cpmask_layer = self.findLayer(to_layer, True)
320324
# copper_layer = cpmask_layer
321325
if (copper_layer != False and cpmask_layer != False):
322326
for node in cpmask_layer.xpath("*", namespaces=inkex.NSS):
@@ -528,7 +532,7 @@ def get_layers(self, src):
528532
layer_label = layer.attrib[label_attrib_name]
529533

530534
layer_label_name = layer_label.replace("-invert", "")
531-
layer_label_name = layer_label.replace("-auto", "")
535+
layer_label_name = layer_label_name.replace("-auto", "")
532536

533537
if layer_label_name in self.layer_map.iterkeys():
534538
layer_type = "export"

0 commit comments

Comments
 (0)