## Query: advanced search, command line: function calls available

Functions listed below can be called from a query expression.

### List manipulation

#### llen(lst)

Determine length of a list.

Arguments:

- lst is the list (should be written as list(lst) to make sure no iteration is done)

Return value: integer length of the list.

#### mklist(args...)

Determine length of a list.

Arguments:

Variable number of objects.

Return value: a list built of the objects passed.

#### layerlist()

Returns a list of all layers.

### Math & abstract geometry

#### distance(x1, y1, x2, y2)

Calculate the distance of two points.

Arguments:

- x1: first point, X coordinate
- y1: first point, Y coordinate
- x2: second point, X coordinate
- y2: second point, Y coordinate

Return value: floating point distance value in nanometers.

#### abs(number)

Returns the absolute value of a number

### Object geometry

#### overlap(obj1, obj2, [bloat])

Returns 1 if obj1 and obj2 overlap (even if they are on different layers)

Arguments:

- obj1 and obj2 are objects;
- an optional bloat value, in coords: bloat up (or shrink, if negative) one of the objects by this value before the test.

Return value: 1 for overlap, 0 for no overlap.

#### intersect(obj1, obj2, [bloat])

Returns 1 if obj1 and obj2 intersect (must share a layer)

Arguments:

- obj1 and obj2 are objects;
- an optional bloat value, in coords: bloat up (or shrink, if negative) one of the objects by this value before the test.

Return value: 1 for intersection, 0 for no overlap.

#### pstkring(pstk, minimum_ring_thickness)

Return the number of layers on which the ring of a padstack is too thin.

Arguments:

- pstk is the padstack object
- minimum_ring_thickness is a coordinate value of the minimum ring thickness

Return value: negative on wrong arguments, 0 if the padstack does not violate the minimum_ring_thickness requirement, positive integer (number of violations) otherwise.

### Networks

#### netlist()

Return the netlist.

Arguments: None.

Return value: an unordered list of all networks specified on the edited netlist (which is the netlist the board is currently using). Each item of the list is a net.

#### netterms(net)

Return terminals of a network.

Arguments:

- net is a network of the netlist of the current board.

Return value: an unordered list of objects (each terminal of the network as described by the edited netlist).

#### netobjs(net)

Return terminals and all copper objects galvanically connected to a network.

Arguments:

- net is a network of the netlist of the current board.

Return value: an unordered list of copper objects connected to the network.

#### netsegs(net)

Return a list of objects, one terminal object per disconnecte segment of the network.

Arguments:

- net is a network of the netlist of the current board.

Return value: an unordered list of terminal objects, one picked randomly from each disconnected segment of the net.

#### netbreak(obj, minimum_overlap)

Start a search on a galvanically connected network segment starting from an object (typically returned by netsegs()) and generate a DRC violation if there are copper objects with overlap smaller than the minimum_overlap.

Arguments:

- obj is the starting object of the search
- minimum_overlap is the coordinate value that represents the minimum required ovlerap between copper objects (e.g. 0.5mm)

Return value: a list that represents a DRC violation (or empty list).

#### netshort(obj, minimum_distance)

Start a search on a galvanically connected network segment starting from an object (typically returned by netsegs()) and generate a DRC violation if there are disconnected copper objects with distance smaller than the minimum_distance from the network.

Arguments:

- obj is the starting object of the search
- minimum_distance is the coordinate value that represents the minimum required distance from any non-connected copper objects (e.g. 0.5mm)

Return value: a list that represents a DRC violation (or empty list).

### Object accessors

#### subcobjs(subc)

Return a list of objects that are within the subc.

Arguments:

- subc is an object of type subcircuit

Return value: an unordered list of objects.

#### poly_num_islands(poly)

Return the number of visible polygon islands.

Arguments:

- poly is the polygon object

Return value: 0 if the polygon has been cleared out of existnece, 1 for normal polygons and a positive integer higher than 1 if the polygon has the FULLPOLY flag and is sliced into multiple parts not naturally connected by the polygon itself.

#### thermal_on(tobj, lobj)

Return a string description of thermals of tobj on layer corrseponding to lobj.

Arguments:

- tobj is the object whose thermals are being queried
- lobj is either a layer or an object-on-a-layer, and it addresses the layer to query the thermals on

Return value: a string that consists of:

- empty if there's no thermal; or
- a single 'n' for no-shape; or
- a single '@' for solid connection; or
- 'o' for round, 'x' for sharp thermal
- in case of round or sharp thermal, a 'd' suffix if it is diagonal

### Misc

#### action(args...)

Execute a pcb-rnd action.

Arguments: variable nunmber of objects and constants.

Return value: invalid on error, or the return value of the action.

#### getconf(path)

Fetch the value of a config node

Arguments:

- path is a conf node path, e.g. editor/grid

Return value: invalid if the config node doesn't exist, else the value of the config node (converted to the most appropriate data type).

#### violation(i1, v1, ..., iN, vN)

Build a DRC violation report (a list object).

Arguments (a variable number of pairs of instruction and value):

- i is an instruction, see below.
- v is a value (a constant or an object)

Instruction is one of the following constants:

- DRCGRP1 - the following v is an object, part of group 1 of offending objects
- DRCGRP2 - the following v is an object, part of group 2 of offending objects
- DRCEXPECT - the following v is a numeric value that represent the expected value
- DRCMEASURE - the following v is a numeric value that represent the measured value that mismatches the expected value

Return value: a list suitable for the drc_query to process.