Index: footprint.c =================================================================== --- footprint.c (revision 27332) +++ footprint.c (revision 27333) @@ -274,9 +274,10 @@ } -int tedax_fp_fsave(pcb_data_t *data, FILE *f) +int tedax_fp_fsave(pcb_data_t *data, FILE *f, long subc_idx) { int res = 0; + long cnt = 0; fprintf(f, "tEDAx v1\n"); @@ -283,17 +284,20 @@ PCB_SUBC_LOOP(data) { - const char *fpname = pcb_attribute_get(&subc->Attributes, "tedax::footprint"); - if (fpname == NULL) - fpname = pcb_attribute_get(&subc->Attributes, "visible_footprint"); - if (fpname == NULL) - fpname = pcb_attribute_get(&subc->Attributes, "footprint"); - if ((fpname == NULL) && (subc->refdes != NULL)) - fpname = subc->refdes; - if (fpname == NULL) - fpname = "-"; + if ((subc_idx == -1) || (subc_idx == cnt)) { + const char *fpname = pcb_attribute_get(&subc->Attributes, "tedax::footprint"); + if (fpname == NULL) + fpname = pcb_attribute_get(&subc->Attributes, "visible_footprint"); + if (fpname == NULL) + fpname = pcb_attribute_get(&subc->Attributes, "footprint"); + if ((fpname == NULL) && (subc->refdes != NULL)) + fpname = subc->refdes; + if (fpname == NULL) + fpname = "-"; - res |= tedax_fp_fsave_subc(subc, fpname, 0, f); + res |= tedax_fp_fsave_subc(subc, fpname, 0, f); + } + cnt++; } PCB_END_LOOP; @@ -301,7 +305,7 @@ return res; } -int tedax_fp_save(pcb_data_t *data, const char *fn) +int tedax_fp_save(pcb_data_t *data, const char *fn, long subc_idx) { int res; FILE *f; @@ -311,7 +315,7 @@ pcb_message(PCB_MSG_ERROR, "tedax_fp_save(): can't open %s for writing\n", fn); return -1; } - res = tedax_fp_fsave(data, f); + res = tedax_fp_fsave(data, f, subc_idx); fclose(f); return res; } Index: footprint.h =================================================================== --- footprint.h (revision 27332) +++ footprint.h (revision 27333) @@ -1,8 +1,8 @@ #include "data.h" #include -int tedax_fp_save(pcb_data_t *data, const char *fn); -int tedax_fp_fsave(pcb_data_t *data, FILE *f); +int tedax_fp_save(pcb_data_t *data, const char *fn, long subc_idx); +int tedax_fp_fsave(pcb_data_t *data, FILE *f, long subc_idx); int tedax_fp_load(pcb_data_t *data, const char *fn, int multi, const char *blk_id, int silent); /* parse a single footprint at current file pos; returns NULL on error */ Index: io_tedax.c =================================================================== --- io_tedax.c (revision 27332) +++ io_tedax.c (revision 27333) @@ -79,7 +79,7 @@ } if (pcb_strcasecmp(type, "board-footprints") == 0) { - PCB_ACT_IRES(tedax_fp_save(PCB->Data, fname)); + PCB_ACT_IRES(tedax_fp_save(PCB->Data, fname, -1)); return 0; } @@ -183,18 +183,18 @@ return tedax_fp_load(Ptr, name, 0, NULL, 0); } -static int io_tedax_write_element(pcb_plug_io_t *ctx, FILE *f, pcb_data_t *dt) +static int io_tedax_write_element(pcb_plug_io_t *ctx, FILE *f, pcb_data_t *dt, long subc_idx) { - return tedax_fp_fsave(dt, f); + return tedax_fp_fsave(dt, f, subc_idx); } -static int io_tedax_write_buffer_subc(pcb_plug_io_t *ctx, FILE *f, pcb_buffer_t *buff, long idx) +static int io_tedax_write_buffer_subc(pcb_plug_io_t *ctx, FILE *f, pcb_buffer_t *buff, long subc_idx) { - if (idx != 0) { + if (subc_idx != 0) { pcb_message(PCB_MSG_ERROR, "Only the first subcircuit cna be saved at the moment\n"); return -1; } - return tedax_fp_fsave(buff->Data, f); + return tedax_fp_fsave(buff->Data, f, subc_idx); } static int io_tedax_test_parse(pcb_plug_io_t *plug_ctx, pcb_plug_iot_t typ, const char *Filename, FILE *f)