Useful Ruby Modules

This is a collection of useful ruby modules. These scripts may also serve as a starting point for custom developments. Please also check these resources:

All .lym macros are installed by one of these ways:

These scripts are made available here:

Anisotropic scaling

Download link: scale_anisotropic.lym

This script installs a new menu entry in the "Edit" menu in the "Selection" submenu called "Anisotropic Scaling" before the "Scale" entry. It asks for two scaling factors for x and y (separated by comma) and applies a different scaling in both directions on the selected shapes. This is a simple implementation which does not check for rounding issues (gaps) and does not support scaling of instances. Paths are converted to polygons because in the general case a constant width cannot be maintained.

Array of Labels

Download link: array_of_labels.lym

This script will install a new entry in the "Macros" menu called "Create array of labels for manifold pins". On running it, a dialog will be shown where you can enter the parameters of your label array. Each label is given an individual number which can be embedded in the label string.

The parameters are:

Upon "Ok", the label sequence will be generated. Undo/redo is available.

Compute the total area of all selected shapes

Download link: calc_area.lym

This script installs a new menu entry in the "Tools" menu called "Compute total area of selected shapes". It sums up the area of all shapes selected. Caution: this is a simple sum of areas. Areas where the shapes overlap are counted twice.

Compute the total area of all selected layers (hierarchical)

Download link: calc_area_hier.lym

This script installs a new menu entry in the "Tools" menu called "Compute layer area". It computes the total area of all layers selected. Caution: this is a simple sum of shape areas, weighted with the cell's instant counts. Areas where the shapes overlap are counted twice.

Search for odd-width paths

Download link: search_odd_width_paths.lym

This script installs a menu entry in the "Tools" menu called "Find Paths With Odd Width". It will find all paths with an odd width in database units in the current layout and report them. Such paths cannot be saved to OASIS, hence it's important to remove them before a layout can be written to OASIS.

Replace cells with others from another file

Download link: replace_cells.lym

The script installs a new menu entry at the end of the cell list context menu: "Replace Cells With Others". This function asks for a file containing a couple of other (top) cells, even with their own hierarchy. It will copy these cells into the existing layout and replace the corresponding cells in the current layout with the ones from the replacement library.

Hint: the script requires the database unit of the replacement and original file to be identical.

Write all child cells of the current cell to new files

Download link: write_childcells.lym

The script installs a new menu entry at the end of the cell list context menu: "Write Child Cells". This function asks for the hierarchy level and writes all cells at this level (below the current cell) to files called "{cellname}.gds".

Dump all shapes of the current cell recursively to a XML file

Download link: dump_flat_shapes.lym

This script installs a menu entry in the "Tools" menu called "Dump Flat Shapes". It asks for a file name and writes a flat dump of the current cell to this file. This dump contains all shapes of the cell and their chip cells projected into the top cell.

The format of the dump file is XML with that layout:

<shape_dump cell="{cell name}" dbu="{database unit}">
  <layer source="{layer}">
    .. shapes on that layer using these XML elements: ..
    <box>{box description}</box>
    <path>{path description}</path>
    <polygon>{polygon description}</polygon>
    <text>{text description}</text>
    .. more shapes ..
  </layer>
  .. more layers ..
</shape_dump>

List all layers under a ruler

Download link: list_layers.lym

This script will install a new entry in the "Tools" menu called "List Layers". Before this function can be used, a single ruler must be drawn. The script looks for shapes that are crossed by this ruler and reports the layers of those shapes. The script can operate on multiple layouts as well.

Rename all cells

Download link: rename_cells.lym

This script will install a new entry in the "Tools" menu called "Rename Cells". It will ask for a rename expression and rename all cells of the current layout. In the expression, "*" is a placeholder for the current cell name and "#" a placeholder for the cell index. Hence it is possible for example to add an "A" prefix by using an expression of "A*". Also it's possible to remove all traces of macro names by using "CELL#" as the expression.

Compute the bounding box of a cell

Download link: cell_bbox.lym

This script will install a new entry in the "Tools" menu called "Cell Bounding Box". It will compute and output the bounding box over all layers of the current cell (the one that is shown in the layout view and which is in the active cell tree). The ouput will include the corner coordinates as well as width and height.

Take a screenshot with options

Download link: screenshot.lym

This macro will provide a screenshot function with a dialog to enter the pixel dimensions. This script will install a new entry in the "File" menu called "Screenshot With Options".