From b7320a6b586e8cf12ea126e7ed4320e6d9f53e99 Mon Sep 17 00:00:00 2001 From: opiopan Date: Mon, 1 Apr 2019 21:26:26 +0900 Subject: add examples --- examples/panelize.py | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100755 examples/panelize.py (limited to 'examples/panelize.py') diff --git a/examples/panelize.py b/examples/panelize.py new file mode 100755 index 0000000..1c5c0da --- /dev/null +++ b/examples/panelize.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python + +import sys, os +import gerberex +from gerberex import DxfFile, GerberComposition, DrillComposition + +exts = ['GTL', 'GTO', 'GTP', 'GTS', 'GBL', 'GBO', 'GBP', 'GBS', 'TXT'] +boards=[ + ('inputs/sonopi-digi.', 0, 0, 0), + ('inputs/sonopi-digi.', 0, 22.5, 0), + ('inputs/rcstick-f-small.', 0, 60, 0), + ('inputs/rcstick-f-small.', 20, 60, 0), + ('inputs/rcstick-f-small.', 40, 60, 0), + ('inputs/rcstick-f.', 92.216, 55.238, 190), + ('inputs/rcstick-jig.', 0, 44, 0), + ('inputs/stm32breakout.', 78.0, 59.36, 90), + ('inputs/stm32breakout.', 100.0, 59.36, 90), +] +outline = 'inputs/outline.dxf' +mousebites = 'inputs/mousebites.dxf' +fill = 'inputs/fill.dxf' +outputs = 'outputs/panelized' + +os.chdir(os.path.dirname(__file__)) +try: + os.mkdir('outputs') +except FileExistsError: + pass + +def putstr(text): + sys.stdout.write(text) + sys.stdout.flush() + +for ext in exts: + putstr('merging %s: ' % ext) + if ext == 'TXT': + ctx = DrillComposition() + else: + ctx = GerberComposition() + for path, x_offset, y_offset, theta in boards: + file = gerberex.read(path + ext) + file.to_metric() + file.rotate(theta) + file.offset(x_offset, y_offset) + ctx.merge(file) + putstr('.') + if ext == 'TXT': + file = gerberex.read(mousebites) + file.draw_mode = DxfFile.DM_MOUSE_BITES + file.width = 0.5 + file.format = (3, 3) + ctx.merge(file) + else: + file = gerberex.read(outline) + ctx.merge(file) + ctx.dump(outputs + '.' + ext) + putstr(' end\n') + +putstr('generating GML: ') +file = gerberex.read(outline) +file.write(outputs + '.GML') +putstr('.') +ctx = GerberComposition() +file = gerberex.read(fill) +file.to_metric() +file.draw_mode = DxfFile.DM_FILL +ctx.merge(file) +ctx.dump(outputs + '-fill.GML') + +putstr('. end\n') -- cgit From cb420e39e278f7ab6f002600a7698d7be101eb7d Mon Sep 17 00:00:00 2001 From: opiopan Date: Wed, 3 Apr 2019 00:30:00 +0900 Subject: fix a rotaion issue --- examples/panelize.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'examples/panelize.py') diff --git a/examples/panelize.py b/examples/panelize.py index 1c5c0da..34cc446 100755 --- a/examples/panelize.py +++ b/examples/panelize.py @@ -37,16 +37,17 @@ for ext in exts: ctx = DrillComposition() else: ctx = GerberComposition() - for path, x_offset, y_offset, theta in boards: + for path, x_offset, y_offset, angle in boards: file = gerberex.read(path + ext) file.to_metric() - file.rotate(theta) + file.rotate(angle) file.offset(x_offset, y_offset) ctx.merge(file) putstr('.') if ext == 'TXT': file = gerberex.read(mousebites) file.draw_mode = DxfFile.DM_MOUSE_BITES + file.to_metric() file.width = 0.5 file.format = (3, 3) ctx.merge(file) -- cgit From 244fcaa5346f4fad819cc2b72857cfb2c472944a Mon Sep 17 00:00:00 2001 From: Hiroshi Murayama Date: Sat, 28 Dec 2019 23:45:33 +0900 Subject: add a function that generate filled gerberdata with representing internal shape by fliping polarity --- examples/panelize.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'examples/panelize.py') diff --git a/examples/panelize.py b/examples/panelize.py index 34cc446..20a2cac 100755 --- a/examples/panelize.py +++ b/examples/panelize.py @@ -18,7 +18,6 @@ boards=[ ] outline = 'inputs/outline.dxf' mousebites = 'inputs/mousebites.dxf' -fill = 'inputs/fill.dxf' outputs = 'outputs/panelized' os.chdir(os.path.dirname(__file__)) @@ -62,9 +61,11 @@ file = gerberex.read(outline) file.write(outputs + '.GML') putstr('.') ctx = GerberComposition() -file = gerberex.read(fill) -file.to_metric() +base = gerberex.rectangle(width=100, height=100, left=0, bottom=0, units='metric') +base.draw_mode = DxfFile.DM_FILL +ctx.merge(base) file.draw_mode = DxfFile.DM_FILL +file.negate_polarity() ctx.merge(file) ctx.dump(outputs + '-fill.GML') -- cgit