# layout package

Layout package searches and manipulates the current layout. Dimension units are in nanometer unless otherwise mentioned.

## Page: board dimensions

Functions used to query or set width and height of the drawing:

- int layout_get_page_width();
- int layout_get_page_height();
- void layout_set_page_size(int width, int height);

## Layer manipulation

Most functions perform operations similar to user commands affecting the current layer. The following few calls can change the current layer. Warning: this is the same current layer as the user's; the script most probably wants to save the current layer before changing it and then restore it after the operation.

- int layout_resolve_layer(const char *name): resolve layer number by name (case sensitive); returns negative number if not found
- int layout_get_current_layer(): returns the number of the current layer
- void layout_switch_to_layer(int layer): switch to layer (further actions will take place there)

## Object searches

Search results are collected on lists identified by their name (search_ID). If a new search is done with the same name, old search results for that name are discarded. Search functions return the number of objects found (size of the list) that can be then used while querying the results using layout_search_get(). Results should be freed using layout_search_free() when they are no longer needed.

TODO: validity of a list in time

Once the search list is ready, the script can iterate over it and resolve the object handle of each object found, using layout_search_get(). Having an object handle, The layout_obj_*() functions may be used by the script to access fields of an object structure.

## Create new objects

The layout_create_*() calls are used to create new objects on the current layer (set by layout_switch_to_layer()).

## API reference - page, units and coordinates

(angles are in radian) TODO

## API reference - debug draw

TODO