Index: trunk/src/board.c =================================================================== --- trunk/src/board.c (revision 16003) +++ trunk/src/board.c (revision 16004) @@ -277,6 +277,14 @@ } } +void pcb_board_set_unit(pcb_board_t *pcb, const pcb_unit_t *new_unit) +{ + if (new_unit != NULL && new_unit->allow != PCB_UNIT_NO_PRINT) { + conf_set(CFR_DESIGN, "editor/grid_unit", -1, new_unit->suffix, POL_OVERWRITE); + pcb_attrib_put(pcb, "PCB::grid::unit", new_unit->suffix); + } +} + /* sets a new line thickness */ void pcb_board_set_line_width(pcb_coord_t Size) { Index: trunk/src/board.h =================================================================== --- trunk/src/board.h (revision 16003) +++ trunk/src/board.h (revision 16004) @@ -149,9 +149,11 @@ /* free the board and remove its undo list */ void pcb_board_remove(pcb_board_t *Ptr); -/* sets cursor grid with respect to grid offset values */ +/* sets cursor grid with respect to grid offset values or default unit*/ void pcb_board_set_grid(pcb_coord_t Grid, pcb_bool align, pcb_coord_t ox, pcb_coord_t oy); +void pcb_board_set_unit(pcb_board_t *pcb, const pcb_unit_t *new_unit); + /* sets a new line thickness */ void pcb_board_set_line_width(pcb_coord_t Size); Index: trunk/src/gui_act.c =================================================================== --- trunk/src/gui_act.c (revision 16003) +++ trunk/src/gui_act.c (revision 16004) @@ -1640,10 +1640,7 @@ return 0; new_unit = get_unit_struct(argv[0]); - if (new_unit != NULL && new_unit->allow != PCB_UNIT_NO_PRINT) { - conf_set(CFR_DESIGN, "editor/grid_unit", -1, new_unit->suffix, POL_OVERWRITE); - pcb_attrib_put(PCB, "PCB::grid::unit", argv[0]); - } + pcb_board_set_unit(PCB, new_unit); return 0; }