Added holes color configuration to pcb_print
This commit is contained in:
parent
b7b9b70ac3
commit
460ddc6a59
|
|
@ -1552,8 +1552,9 @@ Next time you need this list just use an alias, like this:
|
||||||
- `pages`: [list(dict)] List of pages to include in the output document.
|
- `pages`: [list(dict)] List of pages to include in the output document.
|
||||||
Each page contains one or more layers of the PCB.
|
Each page contains one or more layers of the PCB.
|
||||||
* Valid keys:
|
* Valid keys:
|
||||||
- `black_holes`: [boolean=true] Change the drill holes to be black instead of white.
|
- `colored_holes`: [boolean=true] Change the drill holes to be colored instead of white.
|
||||||
- `exclude_pads_from_silkscreen`: [boolean=false] Do not plot the component pads in the silk screen (KiCad 5.x only).
|
- `exclude_pads_from_silkscreen`: [boolean=false] Do not plot the component pads in the silk screen (KiCad 5.x only).
|
||||||
|
- `holes_color`: [string='#000000'] Color used for the holes when `colored_holes` is enabled.
|
||||||
- `layers`: [list(dict)] List of layers printed in this page. Order is important, the last goes on top.
|
- `layers`: [list(dict)] List of layers printed in this page. Order is important, the last goes on top.
|
||||||
* Valid keys:
|
* Valid keys:
|
||||||
- `color`: [string=''] Color used for this layer.
|
- `color`: [string=''] Color used for this layer.
|
||||||
|
|
|
||||||
|
|
@ -984,10 +984,12 @@ outputs:
|
||||||
# [list(dict)] List of pages to include in the output document.
|
# [list(dict)] List of pages to include in the output document.
|
||||||
# Each page contains one or more layers of the PCB
|
# Each page contains one or more layers of the PCB
|
||||||
pages:
|
pages:
|
||||||
# [boolean=true] Change the drill holes to be black instead of white
|
# [boolean=true] Change the drill holes to be colored instead of white
|
||||||
- black_holes: true
|
- colored_holes: true
|
||||||
# [boolean=false] Do not plot the component pads in the silk screen (KiCad 5.x only)
|
# [boolean=false] Do not plot the component pads in the silk screen (KiCad 5.x only)
|
||||||
exclude_pads_from_silkscreen: false
|
exclude_pads_from_silkscreen: false
|
||||||
|
# [string='#000000'] Color used for the holes when `colored_holes` is enabled
|
||||||
|
holes_color: '#000000'
|
||||||
# [list(dict)] List of layers printed in this page. Order is important, the last goes on top
|
# [list(dict)] List of layers printed in this page. Order is important, the last goes on top
|
||||||
layers:
|
layers:
|
||||||
# [string=''] Color used for this layer
|
# [string=''] Color used for this layer
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ PDF2PS = 'pdf2ps'
|
||||||
|
|
||||||
# - Use PyPDF2 for pdfunite
|
# - Use PyPDF2 for pdfunite
|
||||||
# - Implement pad, vias, etc colors
|
# - Implement pad, vias, etc colors
|
||||||
# - Allow hole color config
|
|
||||||
# - move(1,1)? Really needed? 0,0?
|
# - move(1,1)? Really needed? 0,0?
|
||||||
# - Analyze KiCad 6 long delay
|
# - Analyze KiCad 6 long delay
|
||||||
# - Manually draw the frame
|
# - Manually draw the frame
|
||||||
|
|
@ -72,21 +71,22 @@ def to_gray_hex(color):
|
||||||
return '#'+avg_str+avg_str+avg_str
|
return '#'+avg_str+avg_str+avg_str
|
||||||
|
|
||||||
|
|
||||||
def load_svg(file, color, black_holes, monochrome):
|
def load_svg(file, color, colored_holes, holes_color, monochrome):
|
||||||
with open(file, 'rt') as f:
|
with open(file, 'rt') as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
color = color[:7]
|
color = color[:7]
|
||||||
if monochrome:
|
if monochrome:
|
||||||
color = to_gray_hex(color)
|
color = to_gray_hex(color)
|
||||||
if black_holes:
|
holes_color = to_gray_hex(holes_color)
|
||||||
|
if colored_holes:
|
||||||
content = content.replace('#FFFFFF', '**black_hole**')
|
content = content.replace('#FFFFFF', '**black_hole**')
|
||||||
if color != '#000000':
|
if color != '#000000':
|
||||||
# Files plotted
|
# Files plotted
|
||||||
content = content.replace('#000000', color)
|
content = content.replace('#000000', color)
|
||||||
# Files generated by "Print"
|
# Files generated by "Print"
|
||||||
content = content.replace('stroke:rgb(0%,0%,0%)', 'stroke:'+color)
|
content = content.replace('stroke:rgb(0%,0%,0%)', 'stroke:'+color)
|
||||||
if black_holes:
|
if colored_holes:
|
||||||
content = content.replace('**black_hole**', '#000000')
|
content = content.replace('**black_hole**', holes_color)
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -106,12 +106,12 @@ def to_inches(w):
|
||||||
return val
|
return val
|
||||||
|
|
||||||
|
|
||||||
def merge_svg(input_folder, input_files, output_folder, output_file, black_holes, monochrome):
|
def merge_svg(input_folder, input_files, output_folder, output_file, colored_holes, holes_color, monochrome):
|
||||||
""" Merge all pages into one """
|
""" Merge all pages into one """
|
||||||
first = True
|
first = True
|
||||||
for (file, color) in input_files:
|
for (file, color) in input_files:
|
||||||
file = os.path.join(input_folder, file)
|
file = os.path.join(input_folder, file)
|
||||||
new_layer = fromstring(load_svg(file, color, black_holes, monochrome))
|
new_layer = fromstring(load_svg(file, color, colored_holes, holes_color, monochrome))
|
||||||
width = get_width(new_layer)
|
width = get_width(new_layer)
|
||||||
if first:
|
if first:
|
||||||
svg_out = new_layer
|
svg_out = new_layer
|
||||||
|
|
@ -248,8 +248,10 @@ class PagesOptions(Optionable):
|
||||||
""" Do not plot the component pads in the silk screen (KiCad 5.x only) """
|
""" Do not plot the component pads in the silk screen (KiCad 5.x only) """
|
||||||
self.tent_vias = True
|
self.tent_vias = True
|
||||||
""" Cover the vias """
|
""" Cover the vias """
|
||||||
self.black_holes = True
|
self.colored_holes = True
|
||||||
""" Change the drill holes to be black instead of white """
|
""" Change the drill holes to be colored instead of white """
|
||||||
|
self.holes_color = '#000000'
|
||||||
|
""" Color used for the holes when `colored_holes` is enabled """
|
||||||
self.sort_layers = False
|
self.sort_layers = False
|
||||||
""" Try to sort the layers in the same order that uses KiCad for printing """
|
""" Try to sort the layers in the same order that uses KiCad for printing """
|
||||||
self.layers = LayerOptions
|
self.layers = LayerOptions
|
||||||
|
|
@ -265,6 +267,8 @@ class PagesOptions(Optionable):
|
||||||
self.layers.sort(key=lambda x: get_priority(x._id), reverse=True)
|
self.layers.sort(key=lambda x: get_priority(x._id), reverse=True)
|
||||||
if self.sheet_reference_color:
|
if self.sheet_reference_color:
|
||||||
self.validate_color('sheet_reference_color')
|
self.validate_color('sheet_reference_color')
|
||||||
|
if self.holes_color:
|
||||||
|
self.validate_color('holes_color')
|
||||||
|
|
||||||
|
|
||||||
class PCB_PrintOptions(VariantOptions):
|
class PCB_PrintOptions(VariantOptions):
|
||||||
|
|
@ -488,7 +492,7 @@ class PCB_PrintOptions(VariantOptions):
|
||||||
else:
|
else:
|
||||||
assembly_file = GS.pcb_basename+"-"+str(n+1)+".svg"
|
assembly_file = GS.pcb_basename+"-"+str(n+1)+".svg"
|
||||||
logger.debug('- Merging layers to {}'.format(assembly_file))
|
logger.debug('- Merging layers to {}'.format(assembly_file))
|
||||||
merge_svg(temp_dir, filelist, temp_dir, assembly_file, p.black_holes, p.monochrome)
|
merge_svg(temp_dir, filelist, temp_dir, assembly_file, p.colored_holes, p.holes_color, p.monochrome)
|
||||||
if self.format in ['PNG', 'EPS']:
|
if self.format in ['PNG', 'EPS']:
|
||||||
id = self._expand_id+('_page_%02d' % (n+1))
|
id = self._expand_id+('_page_%02d' % (n+1))
|
||||||
out_file = self.expand_filename(output_dir, self.output, id, self._expand_ext)
|
out_file = self.expand_filename(output_dir, self.output, id, self._expand_ext)
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ outputs:
|
||||||
sheet: Front
|
sheet: Front
|
||||||
sheet_reference_color: "#A02020"
|
sheet_reference_color: "#A02020"
|
||||||
# black_holes: false
|
# black_holes: false
|
||||||
|
# holes_color: "#8080FF"
|
||||||
layers:
|
layers:
|
||||||
- layer: Edge.Cuts
|
- layer: Edge.Cuts
|
||||||
- layer: F.Cu
|
- layer: F.Cu
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue