Design reuse
Rooms, reuse blocks, and pin and gate swap.
The board’s Reuse panel (right side; Electronics Designer: Show Reuse Panel) groups rooms, reuse blocks and swap groups. Formats, fields and the limits against Altium and Allegro are in design-reuse.md.
Rooms#
A room is a room:<name> rule area (it keeps nothing out) on the user layer named Rooms; its rules live in the
.kicad_pro file under softforge.rooms: members (a schematic sheet instance and/or references), side, a height
limit and a component clearance. KiCad opens the board unchanged and shows the rooms as rule areas.
Rooms from sheets makes one room per sheet instance (around its parts, or tiled over the board with the parts
packed inside when they are not placed yet). Later Update PCB places new parts in their sheet’s room. The
Room tool moves a room with its parts (drag inside it) or draws a new one (drag on empty board); Arrange
packs a room’s parts inside it. Rooms grow with their parts: a part is at home in the room that lists its reference,
else in its sheet’s room, and when you move a part partly out of its home room (or Update PCB adds parts to a room
that is full) the room’s outline grows around it in the same undo step as the move. A rectangle room stays a
rectangle; any other outline keeps its shape and takes in the part’s body plus the room’s margin (1 mm unless the
room sets margin). Rooms whose rule area is locked, or that are set fixed, keep their outline (the part is then
reported outside). Fit in a room’s row (room.fit) makes a rectangle room the box of its parts plus the margin
(it may shrink) and grows any other outline around parts outside it. The DRC reports room_part_outside,
room_wrong_side, room_height and room_component_clearance as warnings. Commands: room.list, room.add,
room.set, room.remove, room.fromSheets, room.arrange, room.move, room.fit, room.check
(edsnx room from-sheets board.kicad_pcb --mode wrap).
Reuse blocks#
A block is a hierarchical sheet with its layout, kept as three files: <name>.kicad_sch (the sheet),
<name>.kicad_pcb (a board fragment KiCad opens: footprints, tracks, vias, zones) and <name>.kicad_block.json
(anchor, footprints by sheet-relative key, ports, nets, hash). Make block from selection saves the sheet
instance of the selected parts. The library lists the blocks in the softforge.edsnx.blocks.paths folders and in
blocks/ next to the board; Place adds the block as a new sheet (references in their own range: R101, R201,
…), runs Update PCB and lays out its parts and copper with the instance’s nets. Power symbols get references in the
instance’s range too, written the way KiCad annotates power symbols (#PWR0101, #PWR0201, #FLG0101), so no two
instances, and nothing else in the design, share one. Replicate layout copies one instance’s placement and
routing onto the other instances of the same sheet; Update instances brings outdated instances up to date with
the block file. Each instance shows a badge: in sync, outdated (the block changed), modified (parts moved by hand)
or missing. Commands: block.make, block.list, block.place, block.replicate, block.update
(edsnx block place board.kicad_pcb --block blocks/led-driver --count 2).
Blocks nest: a block’s sheet may hold hierarchical sheets, other blocks among them. Make block then saves the
sub-sheet files with the block (listed under subsheets in the .kicad_block.json) and the parts of every level in
its layout, keyed by their path inside the instance (<sub-sheet uuid>/<symbol uuid>). Place copies the
sub-sheets into the project and numbers the references of every level in the instance’s range (R101, R102, …);
Replicate layout and Update instances match the parts of every level the same way.
Blocks take parameters: a field written as a KiCad text variable, such as a resistor’s Value ${R_VALUE}, is a
parameter of the block, listed with its default under parameters in the .kicad_block.json (Make block finds them;
the defaults come from the source sheet’s fields or the parameters argument). Place asks for each value
(parameters argument: one object for every instance, or a list with one per instance) and writes it as a field of
the instance’s sheet symbol, which KiCad resolves in that instance only: the netlist and the footprints on
the board show each instance’s value.
Pin and gate swap#
Symbols declare swappable pins in a Swap.Groups field (1,2;A1,A2,A3: groups separated by ;), interchangeable
units in Swap.Gates (yes) and alternative footprints in Swap.Footprints; Update PCB copies them to the board.
The Swap pins tool takes two pads of a group: the pads trade nets and the schematic wiring of the two pins is
swapped, so Update PCB stays empty. The copper on the pads keeps its net and follows it to the other pad: each
track is cut back from the pad it leaves until it clears that pad, then joined to the pad that now carries its net,
straight, around the two pads, or, when the two connections would have to cross, through vias on another copper
layer. Every new segment and via keeps the board’s clearance to other nets. A connection with no clean path is
ripped up instead (a ratsnest line to route again, and a warning), never shorted. Shift+click rips up the attached
copper instead of moving it (copper: "ripUp"); copper: "refuse" refuses a swap with attached copper.
swap.gates exchanges two units of a multi-unit part (their pads’ copper follows the same way); swap.part swaps a
footprint for an alternative, or records it as a variant’s footprint override.