Index: trunk/src/netlist_act.c =================================================================== --- trunk/src/netlist_act.c (revision 38233) +++ trunk/src/netlist_act.c (revision 38234) @@ -719,7 +719,7 @@ } break; case F_Remove: - TODO("back annotate breaking connections of the given subc"); + rats_patch_break_subc_conns(pcb, subc, undoable); return rats_patch_del_subc(pcb, subc, undoable); default: rnd_message(RND_MSG_ERROR, "BaSubc(): invalid second argument\n"); Index: trunk/src/rats_patch.c =================================================================== --- trunk/src/rats_patch.c (revision 38233) +++ trunk/src/rats_patch.c (revision 38234) @@ -520,8 +520,28 @@ return 0; } +void rats_patch_break_subc_conns(pcb_board_t *pcb, pcb_subc_t *subc, int undoable) +{ + pcb_netlist_t *netlist = &pcb->netlist[PCB_NETLIST_EDITED]; + htsp_entry_t *e; + for(e = htsp_first(netlist); e != NULL; e = htsp_next(netlist, e)) { + pcb_net_t *net = e->value; + pcb_net_term_t *term, *next; + for(term = pcb_termlist_first(&net->conns); term != NULL; term = next) { + next = pcb_termlist_next(term); + if (strcmp(term->refdes, subc->refdes) == 0) { + char *pinname = rnd_strdup_printf("%s-%s", term->refdes, term->term); + pcb_ratspatch_append_optimize(pcb, RATP_DEL_CONN, pinname, net->name, NULL); + pcb_net_term_del(net, term); + free(pinname); + } + } + } +} + + /**** export ****/ int pcb_rats_patch_export(pcb_board_t *pcb, pcb_ratspatch_line_t *pat, rnd_bool need_info_lines, void (*cb)(void *ctx, pcb_rats_patch_export_ev_t ev, const char *netn, const char *key, const char *val), void *ctx) Index: trunk/src/rats_patch.h =================================================================== --- trunk/src/rats_patch.h (revision 38233) +++ trunk/src/rats_patch.h (revision 38234) @@ -93,6 +93,10 @@ netlist. Returns 0 on sucess.*/ int rats_patch_del_subc(pcb_board_t *pcb, pcb_subc_t *subc, int undoable); +/* Back annotate removal of all connections of a subc */ +void rats_patch_break_subc_conns(pcb_board_t *pcb, pcb_subc_t *subc, int undoable); + + /**** exporter ****/ typedef enum pcb_ratspatch_fmt_e {