Index: trunk/src/obj_subc.c =================================================================== --- trunk/src/obj_subc.c (revision 13122) +++ trunk/src/obj_subc.c (revision 13123) @@ -221,6 +221,28 @@ return poly; } +pcb_layer_t *pcb_loose_subc_layer(pcb_board_t *pcb, pcb_layer_t *layer) +{ + pcb_subc_t *sc; + int n; + + if (!pcb->is_footprint) + return layer; + + sc = pcb_subclist_first(&pcb->Data->subc); + if (sc == NULL) + return layer; + + for(n = 0; n < sc->data->LayerN; n++) { + pcb_layer_t *l = &sc->data->Layer[n]; + if (!l->is_bound) + continue; + if (l->meta.bound.real == layer) + return l; + } + return layer; +} + extern unsigned long pcb_obj_type2oldtype(pcb_objtype_t type); /* Move the pad-side-effect objects to the appropriate layer */ Index: trunk/src/obj_subc.h =================================================================== --- trunk/src/obj_subc.h (revision 13122) +++ trunk/src/obj_subc.h (revision 13123) @@ -101,6 +101,9 @@ /* undoable remove */ void *pcb_subc_remove(pcb_subc_t *sc); +/* In board mode return brd_layer; in footprint edit mode, return the subcircuit + layer that matches brd_layer or brd_layer if not found. */ +pcb_layer_t *pcb_loose_subc_layer(pcb_board_t *pcb, pcb_layer_t *brd_layer); /*** loops ***/ Index: trunk/src/route.c =================================================================== --- trunk/src/route.c (revision 13122) +++ trunk/src/route.c (revision 13123) @@ -444,7 +444,7 @@ for( i=0;isize;i++) { pcb_route_object_t const * p_obj = &p_route->objects[i]; - pcb_layer_t * layer = pcb_get_layer(PCB->Data, p_obj->layer); + pcb_layer_t * layer = pcb_loose_subc_layer(PCB, pcb_get_layer(PCB->Data, p_obj->layer)); switch(p_obj->type) { Index: trunk/src/tool_line.c =================================================================== --- trunk/src/tool_line.c (revision 13122) +++ trunk/src/tool_line.c (revision 13123) @@ -37,6 +37,7 @@ #include "draw_wireframe.h" #include "find.h" #include "obj_line.h" +#include "obj_subc.h" #include "rats.h" #include "search.h" #include "tool.h" @@ -217,7 +218,7 @@ if ((pcb_crosshair.AttachedLine.Point1.X != pcb_crosshair.AttachedLine.Point2.X || pcb_crosshair.AttachedLine.Point1.Y != pcb_crosshair.AttachedLine.Point2.Y) && (line = - pcb_line_new_merge(CURRENT, + pcb_line_new_merge(pcb_loose_subc_layer(PCB, CURRENT), pcb_crosshair.AttachedLine.Point1.X, pcb_crosshair.AttachedLine.Point1.Y, pcb_crosshair.AttachedLine.Point2.X, @@ -262,7 +263,7 @@ } if (conf_core.editor.line_refraction && (pcb_tool_note.X != pcb_crosshair.AttachedLine.Point2.X || pcb_tool_note.Y != pcb_crosshair.AttachedLine.Point2.Y) && (line = - pcb_line_new_merge(CURRENT, + pcb_line_new_merge(pcb_loose_subc_layer(PCB, CURRENT), pcb_crosshair.AttachedLine.Point2.X, pcb_crosshair.AttachedLine.Point2.Y, pcb_tool_note.X, pcb_tool_note.Y,