Index: trunk/src/obj_subc.c =================================================================== --- trunk/src/obj_subc.c (revision 17001) +++ trunk/src/obj_subc.c (revision 17002) @@ -1732,3 +1732,19 @@ pcb_subc_bbox(sc); } + +const char *pcb_subc_name(pcb_subc_t *subc, const char *local_name) +{ + const char *val; + + if (local_name != NULL) { + val = pcb_attribute_get(&subc->Attributes, local_name); + if (val != NULL) + return val; + } + val = pcb_attribute_get(&subc->Attributes, "footprint"); + if (val != NULL) + return val; + val = pcb_attribute_get(&subc->Attributes, "name"); + return val; +} Index: trunk/src/obj_subc.h =================================================================== --- trunk/src/obj_subc.h (revision 17001) +++ trunk/src/obj_subc.h (revision 17002) @@ -125,6 +125,12 @@ /* Returns whether there's no object in the subc */ pcb_bool pcb_subc_is_empty(pcb_subc_t *subc); +/* Return the footprint name; if local_name is not NULL, that attribute + is queried first; if that doesn't exist, "footprint" and then "name" + is returned (or NULL if nothing is found) */ +const char *pcb_subc_name(pcb_subc_t *subc, const char *local_name); + + /* Update the subcircuit (e.g. bbox) after a part of the subcircuit has changed */ void pcb_subc_part_changed_(pcb_any_obj_t *obj); #define pcb_subc_part_changed(obj) pcb_subc_part_changed_((pcb_any_obj_t *)obj)