Index: doc-rnd/gpmi/packages/layout.html =================================================================== --- doc-rnd/gpmi/packages/layout.html (revision 794) +++ doc-rnd/gpmi/packages/layout.html (revision 795) @@ -5,7 +5,7 @@ Layout package searches and manipulates the current layout. Dimension units are in nanometer unless otherwise mentioned. -
-
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. -
- [todo] lists can be merged or copied. [todo] +
Enum values should be passed on as strings.
+
+ layout_object_mask_e
+
+ Object type search mask bits
+
+
value | meaning + |
---|---|
OM_LINE | lines (traces, silk lines, not font) + |
OM_TEXT | text written using the font + |
OM_POLYGON | polygons, including rectangles + |
OM_ARC | arcs, circles + |
OM_VIA | vias and holes which are not part of a footprint + |
OM_PIN | pins/pads of a footprint + |
OM_ANY | shorthand for "find anything" + |
+ Which coordinate of the object is referenced ++
value | meaning + |
---|---|
OC_BX1 | bounding box X1 + |
OC_BX2 | bounding box X2 + |
OC_BY1 | bounding box Y1 + |
OC_BY2 | bounding box Y2 + |
OC_P1X | point 1 X + |
OC_P2X | point 2 X + |
OC_P1Y | point 1 Y + |
OC_P2Y | point 2 Y + |
OC_OBJ | the whole object + |
OC_P1 | point 1 is P1X + |
OC_P2 | point 2 is P2X + |
+ of layout_object_coord_t ++
value | meaning + |
---|---|
FL_NONE | <comment missing in the header> + |
FL_SHOWNUMBER | <comment missing in the header> + |
FL_LOCALREF | <comment missing in the header> + |
FL_CHECKPLANS | <comment missing in the header> + |
FL_SHOWDRC | <comment missing in the header> + |
FL_RUBBERBAND | <comment missing in the header> + |
FL_DESCRIPTION | <comment missing in the header> + |
FL_NAMEONPCB | <comment missing in the header> + |
FL_AUTODRC | <comment missing in the header> + |
FL_ALLDIRECTION | <comment missing in the header> + |
FL_SWAPSTARTDIR | <comment missing in the header> + |
FL_UNIQUENAME | <comment missing in the header> + |
FL_CLEARNEW | <comment missing in the header> + |
FL_SNAPPIN | <comment missing in the header> + |
FL_SHOWMASK | <comment missing in the header> + |
FL_THINDRAW | <comment missing in the header> + |
FL_ORTHOMOVE | <comment missing in the header> + |
FL_LIVEROUTE | <comment missing in the header> + |
FL_THINDRAWPOLY | <comment missing in the header> + |
FL_LOCKNAMES | <comment missing in the header> + |
FL_ONLYNAMES | <comment missing in the header> + |
FL_NEWFULLPOLY | <comment missing in the header> + |
FL_HIDENAMES | <comment missing in the header> + |
FL_THERMALSTYLE1 | <comment missing in the header> + |
FL_THERMALSTYLE2 | <comment missing in the header> + |
FL_THERMALSTYLE3 | <comment missing in the header> + |
FL_THERMALSTYLE4 | <comment missing in the header> + |
FL_THERMALSTYLE5 | <comment missing in the header> + |
+ Field name of the layer structure ++
value | meaning + |
---|---|
LFLD_NUM_LINES | number of lines on the layer + |
LFLD_NUM_TEXTS | number of texts on the layer + |
LFLD_NUM_POLYS | number of polygons on the layer + |
LFLD_NUM_ARCS | number of arcs on the layer + |
LFLD_VISIBLE | non-zero if the layer is visible + |
LFLD_NODRC | non-zero if the layer doesn't use DRC + |
The following functions are registered in script context.
+
+ int layout_search_box(const char* search_ID, layout_object_mask_t obj_types, int x1, int y1, int x2, int y2)
+
+ creates a new search and adds all objects that matches obj_types mask within the given rectangle on the current layer
+ Arguments:
+ search_ID: unique name of the search (overwrites existing search on the same name)
+ obj_types: on or more object types
+ x1, y1, x2, y2: box the search is done within (PCB coords)
+ Returns the number of object on the search list.
+
+
+ int layout_search_selected(const char* search_ID, layout_object_mask_t obj_types)
+
+ creates a new search and adds all selected objects
+ Arguments:
+ search_ID: unique name of the search (overwrites existing search on the same name)
+ obj_types: on or more object types
+ Returns the number of object on the search list.
+
+
+ int layout_search_found(const char* search_ID, layout_object_mask_t obj_types)
+
+ creates a new search and adds all found objects (the green highlight)
+ Arguments:
+ search_ID: unique name of the search (overwrites existing search on the same name)
+ obj_types: on or more object types
+ Returns the number of object on the search list.
+
+
+ layout_object_t* layout_search_get(const char* search_ID, int n)
+
+ Returns the nth object from a search list (or NULL pointer if n is beyond the list)
+
+
+ int layout_search_free(const char* search_ID)
+
+ Frees all memory related to a search. Returns 0 on success.
+ Argument:
+ search_ID: unique name of the search (requires an existing search)
+
+
+ int layout_obj_coord(layout_object_t* obj, layout_object_coord_t coord)
+
+ Return the requested coord of an object; except for the bounding box
+ coordinates, the meaning of coordinates are object-specific.
+ Point 1 and point 2 are usually endpoints of the object (line, arc),
+ "the whole object" coordinate is a central point.
+
+
+ layout_object_mask_t layout_obj_type(layout_object_t* obj)
+
+ Return the type of an object (always a single bit)
+
+
+ int layout_obj_move(layout_object_t* obj, layout_object_coord_t coord, int dx, int dy)
+
+ Change location of an object or parts of the object (like move endpoint of a line);
+ Arguments:
+ obj: the object
+ coord: which coordinate to drag (e.g. move only the endpoint)
+ dx, dy: relative x and y coordinates the selected coordinate is displaced by
+ Returns 0 on success
+
+
+ int layout_arc_angles(layout_object_t* obj, int relative, int start, int delta)
+
+ change angles of an arc; start and delate are relative if relative is non-zero; returns 0 on success
+
+
+ int layout_create_line(int x1, int y1, int x2, int y2, int thickness, int clearance, layout_flag_t flags)
+
+ create a line
+
+
+ int layout_create_via(int x, int y, int thickness, int clearance, int mask, int hole, const char* name, layout_flag_t flags)
+
+ create a named via
+
+
+ int layout_create_arc(int x, int y, int width, int height, int sa, int dir, int thickness, int clearance, layout_flag_t flags)
+
+ create a new arc; sa is start angle, dir is delta angle
+
+
+ void layout_switch_to_layer(int layer)
+
+ switch to layer (further layer-specific actions will take place there)
+
+
+ int layout_get_current_layer()
+
+ returns the number of the current layer
+
+
+ int layout_resolve_layer(const char* name)
+
+ resolve layer number by name (case sensitive); returns negative number if not found
+
+
+ int layout_get_max_possible_layer()
+
+ return the theoretical number of layers supported by PCB
+
+
+ int layout_get_max_copper_layer()
+
+ return the actual number of copper layers on the current design
+
+
+ int layout_get_max_layer()
+
+ return the actual number of layers on the current design
+
+
+ const char* layout_layer_name(int layer)
+
+ return the name of a layer
+
+
+ const char* layout_layer_color(int layer)
+
+ return the color of a layer
+
+
+ int layout_layer_field(int layer, layer_field_t fld)
+
+ return an integer field of a layer
+
+
+ int layout_get_page_width()
+
+ query or set width and height of the drawing
+
+
+ int layout_get_page_height()
+
+<comment missing in the header>
+
+
+ void layout_set_page_size(int width, int height)
+
+<comment missing in the header>
+
+
+ double mil2pcb_multiplier()
+
+ -- coordinate system -- (coord.c)
+
+
+ double mm2pcb_multiplier()
+
+<comment missing in the header>
+
+
+ const char* current_grid_unit()
+
+<comment missing in the header>
+
+
+ int debug_draw_request(void)
+
+ Initialize debug drawing; returns 1 if worked, 0 if denied
+
+
+ void debug_draw_flush(void)
+
+ Flush the drawing
+
+
+ void debug_draw_finish(dctx_t* ctx)
+
+ Finish (close) drawing
+
+
+ dctx_t* debug_draw_dctx(void)
+
+ Get the draw context of debug draw
+
+
+ void draw_set_color(dctx_t* ctx, const char* name)
+
+ Debug draw style: set drawing color
+
+
+ void draw_set_line_width(dctx_t* ctx, int width)
+
+ Debug draw style: set line width
+
+
+ void draw_set_draw_xor(dctx_t* ctx, int xor)
+
+ Debug draw style: set whether drawing should happen in xor
+
+
+ void draw_set_draw_faded(dctx_t* ctx, int faded)
+
+ Debug draw style: set whether drawing should happen in faded mode
+
+
+ void draw_line(dctx_t* ctx, int x1_, int y1_, int x2_, int y2_)
+
+ Debug draw: draw a line using the current style settings
+
+