[user script for footprint designers to auto-number terminals] Corner cases: 1. padstack != terminal In pcb-rnd _anything_ can go in a footprint, including vias. Typical example: high freq (MHz) so(8) or qfn()-like dc/dc converter chip with built-in fet. The datasheet for such devices specify a matrix of vias that _must_ be placed under the center pad, for heat transfer (and you obviously need to make sure you have copper polygons on at leat the outer layers). The most native representation of this: - a large polygonal pastack for the center pad that has copper shape on at least top and bottom, but probably it is a good idea to have copper shape on internal copper too; this one is the center pad terminal - n*m vias placed over the center pad, _not_ marked as terminal Of course one can set the same terminal ID for the vias as was set for the center pad, but that would be strange: these vias are not really pins in any way. For our feature: we don't want to automatically number every padstack, because vias in footprints are legit uses! 2. not only padsatcks can be terminals The padstack object is a simple construct that can handle 99% of the cases. However, there's 1% which it can not. For that 1% we have heavy terminals: you can draw any object on any layer and make it a terminal by setting the term ID. Most typical applications include paste patterns for large copper pads (a matrix of paste rectangles over a pad) or in some rare cases terminals with funky shape that include arc for example. For our feature: we can't say only padstacks should be numbered, because that misses 1% of very important cases! 3. order of numbering The numbering is a mess in the industry. There are IPC and JEDEC standards, which try to straight it out. For most parts it sort of works, like for a long time I haven't seen a so() or *fn() kind of part that was numbered in an unexpected way. But then there's plcc that starts numbering from the top middle and of course sot23 and friends where pin 2 and 3 assignment is pretty random. So we can't do a "walk around counter-clockwise" kind of algo. Especially not when you have BGA... For our feature: we probably can't auto-number a _whole_ footprint because we wimply wouldn't be able to tell the order of numbering. 4. bga numbering: matrix! The most boring to number is probably the BGA. Even the smallest chip will have dozens of pads to deal with. And you don't number them in a round but rather in a matrix, like A1..K12. Plus typically there are missing pins which you skip in the numbering. For our feature: we can't assume a single numbering strategy. 5. terminals can appear outside of subcircuits There's no limitation that terminals can appear only within subcircuits. Of course the netlist will look for refdes-termid pairs at the moment. But there are a few cases when you want to have terminals outside of subcircuits too: - when you build a subcircuit from scratch, in pcb-editor mode, you typically want to number them before you convert to subc - when you break up a subcircuit you want its parts to retain all information, including terminal ID because you may want to build a new subcircuit from them - if you design a PCB module, you may want your own pins be placed as terminals. You could put them in a subcircuit of course, but I don't want to force that For our feature: we can't renumber anything _within subcircuits_, that would be an unreasonable restriction. Considering all these, I think the most viable implementation would be this: 1. an action then a GUI wrapper around it for automated terminal renumbering 2. it's independently of footpritns and subcircuits and padstacks; it operates on selected objects - any object on any layer you select 3. handling of heavy terminals: if two selected objects overlap, they always get the same terminal ID 4. multiple, user selectable numbering algorithm - counter: a starting number or letter; plus for letters a strategy what to do beyond Z and what letters to skip (e.g. I and O). - single row "top-down"/"left-right" or if the user chooses that, reversed ("down/top"/"right-left") numbering with a counter - matrix numbering requires selected objects to be aligned in a regular matrix - fails if anything is out of the detected grid; has two running counters, one for rows, one for columns - if we later figure more common numbering strategies How would you use it in practice: Except for BGA, you typically wouldn't renumber a whole footprint, but groups of pins/pads. For example in case of a dual-row footprint (so() or dip()), you'd select to-be-terminals of one row first, then number them from 1 normally (top-down), then unselect them and select the other row and number them from e.g. 20 in reverse order (down-top). For qfn()-like pads-all-around, you'd need to go in 4 selections. For plcc-like mess, you'd go in 5 selections, breaking the top row to make sure the numbering starts at the center. Any mounting hole, center pad or other special pads are manually numbered (there are typically only a few).