This is working well for me now. I just wrote two library functions to calculate and add the tabs for me. They don't do any checking so they fall over where boards don't match in size but there isn't enough space to add a tab to make them match. Dirty PCBs should make this just fine, they made the panel above just fine.
[attachment=0]
local boards = require 'boards'
local extents = require 'boards.extents'
local panelization = require 'boards.panelization'
local manipulation = require 'boards.manipulation'
local max_panel_lr = 100e9
local max_panel_bt = 100e9
max_panel = panelization.empty_board(max_panel_lr, max_panel_bt)
-- options
spacing = 1.7e9
options = {}
options["spacing"] = spacing
options["routing_mode"] = "stroke"
function merge(name, board1, board2, match_lr)
local board1_extents = extents.compute_board_extents(board1)
local size1_bt = board1_extents["top"]-board1_extents["bottom"]
local size1_lr = board1_extents["right"]-board1_extents["left"]
local board2_extents = extents.compute_board_extents(board2)
local size2_bt = board2_extents["top"]-board2_extents["bottom"]
local size2_lr = board2_extents["right"]-board2_extents["left"]
local merged_panel = {}
if match_lr == 1 then
if size1_lr ~= size2_lr then
local tab = panelization.empty_board(size1_lr - size2_lr - spacing, size2_bt)
local panel = panelization.panelize({board2, tab}, options, false)
merged_panel = panelization.panelize({board1, panel}, options, true)
else
merged_panel = panelization.panelize({board1, board2}, options, true)
end
else
if size1_bt ~= size2_bt then
local tab = panelization.empty_board(size2_lr, size1_bt - size2_bt - spacing)
local panel = panelization.panelize({board2, tab}, options, true)
merged_panel = panelization.panelize({board1, panel}, options, false)
else
merged_panel = panelization.panelize({board1, board2}, options, false)
end
end
local merged_panel_extents = extents.compute_board_extents(merged_panel)
local size_bt = merged_panel_extents["top"]-merged_panel_extents["bottom"]
local size_lr = merged_panel_extents["right"]-merged_panel_extents["left"]
print("merge", name, size_lr, size_bt)
return merged_panel
end
function pcb(filepath, pad_lr_board, pad_bt_board)
local board = assert(boards.load(filepath))
board.images.drill.format.zeros = 'L'
board.images.drill.format.integer = 2
board.images.drill.format.decimal = 6
local board_extents = extents.compute_board_extents(board)
local size_bt = board_extents["top"]-board_extents["bottom"]
local size_lr = board_extents["right"]-board_extents["left"]
print(filepath, size_lr, size_bt)
if pad_lr_board ~= 0 then
local new_extents = extents.compute_board_extents(pad_lr_board)
local new_size_lr = new_extents["right"] - new_extents["left"]
local tab_lr = panelization.empty_board(new_size_lr - size_lr - spacing, size_bt)
local panel_lr = panelization.panelize({board, tab_lr}, options, false)
board = panel_lr
board_extents = extents.compute_board_extents(board)
size_bt = board_extents["top"]-board_extents["bottom"]
size_lr = board_extents["right"]-board_extents["left"]
print("LR Adjusted size", size_lr, size_bt)
end
if pad_bt_board ~= 0 then
local new_extents = extents.compute_board_extents(pad_bt_board)
local new_size_bt = new_extents["top"] - new_extents["bottom"]
local tab_bt = panelization.empty_board(size_lr, new_size_bt - size_bt - spacing)
local panel_bt = panelization.panelize({board, tab_bt}, options, true)
board = panel_bt
board_extents = extents.compute_board_extents(board)
size_bt = board_extents["top"]-board_extents["bottom"]
size_lr = board_extents["right"]-board_extents["left"]
print("BT Adjusted size", size_lr, size_bt)
end
return board
end
local elseq = pcb('../../../../git/sparkfun/EL_Sequencer/Hardware/EL_Sequencer', 0, 0)
local ft231x = pcb('../../../../git/sparkfun/FT231X_Breakout/hardware/ft231x-breakout', 0, 0)
local pstest = pcb('../../eagle/switching-ps-test/switching-ps-test', 0, 0)
local vert1_top = merge("vert1_top", ft231x, pstest, 0)
local vert1 = merge("vert1", elseq, vert1_top, 1)
-- vert2
local ftdibasic = pcb('../../../../git/sparkfun/FTDI_Basic_Breakout-5V/Hardware/FTDI Basic-5V', 0, 0)
local adafruitpowerboost1000c = pcb('../../../../git/adafruit/Adafruit-PowerBoost-1000C/Adafruit PowerBoost 1000C Rev B', 0, 0)
local fadecandy = pcb('../../../../git/scanlime/fadecandy/pcb/fc64x8/fc64x8', ftdibasic, 0)
local vert2 = merge("vert2a", ftdibasic, adafruitpowerboost1000c, 1)
vert2 = merge("vert2b", vert2, fadecandy, 1)
-- vert3
local sparkfunlipo = manipulation.rotate_board(pcb('../../../../git/sparkfun/Lipo_Charger_Basic-microUSB/Hardware/SparkFun_Lipo_Charger_Basic-microUSB', 0, 0), 90)
local tinyavrprog = manipulation.rotate_board(pcb('../../../../git/sparkfun/Tiny-AVR-Programmer/Hardware/Tiny_Programmer', 0, 0), 90)
local vert3 = merge("vert3", tinyavrprog, sparkfunlipo, 1)
-- panel
local panel = merge("panel", vert1, vert2, 0)
panel = merge("panel", panel, vert3, 0)
boards.merge_apertures(panel)
local panel_extents = extents.compute_board_extents(panel)
local panel_bt=panel_extents["top"]-panel_extents["bottom"]
local panel_lr=panel_extents["right"]-panel_extents["left"]
print("panel", panel_lr, panel_bt)
assert(boards.save(panel, './final/tkeddie_201512_1'))
os.exit()