Table Of Contents

Previous topic

The gdsCAD API

Next topic

gdsCAD.shapes

This Page

gdsCAD.core

The primary geometry elements, layout and organization classes.

The objects found here are intended to correspond directly to elements found in the GDSII specification.

The fundamental gdsCAD object is the Layout, which contains all the information to be sent to the mask shop. A Layout can contain multiple Cells which in turn contain references to other Cells, or contain drawing geometry.

Layout
The container holding all design data (GDSII: LIBRARY)
Cell
A collection of drawing elements, and/or references to other Cells (GDSII: STRUCTURE)
Primitive Elements:

These can all be added to a cell. Only Boundary and Path are drawing elements.

  • Boundary: A filled polygon (GDSII: BOUNDARY)
  • Path: An unfilled polygonal line (GDSII: PATH)
  • Text: Non-printing labelling text (GDSII: TEXT)
  • CellReference: A simple reference to another Cell (GDSII: SREF)
  • CellArray: A reference to another cell to be copied multiple times (GDSII: AREF)
  • Elements: A listlike collection of Boundary or Path drawing elements (no GDSII equivalent)

Note

Copyright 2009-2012 Lucas Heitzmann Gabrielli

Copyright 2013 Andrew G. Mark

gdsCAD (based on gdspy) is released under the terms of the GNU GPL

Inheritance Diagram

Inheritance diagram of gdsCAD.core

Class and Function Summary

Layout([name, unit, precision]) A layout object
Cell(name) Collection of elements, both geometric objects and references to other cells.
Boundary(points[, layer, datatype, verbose, ...]) A filled, closed polygonal geometric object.
Path(points[, width, layer, datatype, ...]) An unfilled, unclosed polygonal line of fixed width.
Elements([obj, layer, datatype, obj_type]) A list-like collection of Boundary and/or Path objects.
CellReference(ref_cell[, origin, rotation, ...]) Simple reference to an existing cell.
CellArray(ref_cell, cols, rows, spacing[, ...]) Multiple references to an existing cell in a grid arrangement.
GdsImport(infile[, rename, layers, ...]) Import a new Layout from a GDSII stream file.

Module Definition

The primary geometry elements, layout and organization classes.

The objects found here are intended to correspond directly to elements found in the GDSII specification.

The fundamental gdsCAD object is the Layout, which contains all the information to be sent to the mask shop. A Layout can contain multiple Cells which in turn contain references to other Cells, or contain drawing geometry.

Layout
The container holding all design data (GDSII: LIBRARY)
Cell
A collection of drawing elements, and/or references to other Cells (GDSII: STRUCTURE)
Primitive Elements:

These can all be added to a cell. Only Boundary and Path are drawing elements.

  • Boundary: A filled polygon (GDSII: BOUNDARY)
  • Path: An unfilled polygonal line (GDSII: PATH)
  • Text: Non-printing labelling text (GDSII: TEXT)
  • CellReference: A simple reference to another Cell (GDSII: SREF)
  • CellArray: A reference to another cell to be copied multiple times (GDSII: AREF)
  • Elements: A listlike collection of Boundary or Path drawing elements (no GDSII equivalent)

Note

Copyright 2009-2012 Lucas Heitzmann Gabrielli

Copyright 2013 Andrew G. Mark

gdsCAD (based on gdspy) is released under the terms of the GNU GPL

class gdsCAD.core.Boundary(points, layer=None, datatype=None, verbose=False, dtype=<type 'numpy.float32'>)[source]

Bases: gdsCAD.core.ElementBase

A filled, closed polygonal geometric object.

Parameters:
  • points – Coordinates of the vertices of the polygon.
  • layer – The GDSII layer number for this element Defaults to core.default_layer.
  • datatype – The GDSII datatype for this element (between 0 and 255).
  • verbose – If False, warnings about the number of vertices of the polygon will be suppressed.

Note

This is a direct equivalent to the Boundary element found in the GDSII specification.

The last point should not be equal to the first (polygons are automatically closed).

The official GDSII specification supports only a maximum of 199 vertices per polygon.

Examples::
triangle_pts = [(0, 40), (15, 40), (10, 50)] triangle = gdsCAD.core.Boundary(triangle_pts) myCell.add(triangle)
area()[source]

Calculates the area of the element.

Assumes that the Boundary respects the GDSII requirement that the path be simple and closed.

artist()[source]

Return a list of matplotlib artists to draw this object

bounding_box

Return the bounding box containing the polygon

copy(suffix=None)

Make a copy of this element.

Parameters:suffix – Ignored
points
reflect(axis, origin=(0, 0))

Reflect this object in the x or y axis

Parameters:
  • axis – ‘x’ or ‘y’ indicating which axis in which to make the refln
  • origin – A point which will remain invariant on reflection
Returns:

self

Optional origin can be a 2D vector or ‘COM’ indicating that scaling should be made about the pts centre of mass.

The transformation acts in place.

rotate(angle, center=(0, 0))

Rotate this object.

Parameters:
  • angle – The angle of rotation (in deg).
  • center – Center point for the rotation.
Returns:

self

The optional center point can be specified by a 2D vector or the string ‘com’ for center of mass.

The transformation acts in place.

scale(k, origin=(0, 0))

Scale this object by the factor k

Parameters:
  • k – the value by which to scale the object
  • origin – the point about which to make the scaling
Returns:

self

The factor k can be a scalar or 2D vector allowing non-uniform scaling. Optional origin can be a 2D vector or ‘COM’ indicating that scaling should be made about the pts centre of mass.

The transformation acts in place.

show()

Display the object

Returns:the display Axes.
to_gds(multiplier)[source]

Convert this object to a GDSII element.

Parameters:multiplier – A number that multiplies all dimensions written in the GDSII element.
Returns:The GDSII binary string that represents this object.
to_path(width=1.0, pathtype=0)[source]

Convert this Boundary to a Path

Parameters:
  • width – The width of the line
  • pathtype – The endpoint style
translate(displacement)

Translate this object.

Parameters:displacment – The vector by which to displace this object.
Returns:self

The transformation acts in place.

class gdsCAD.core.Cell(name)[source]

Bases: object

Collection of elements, both geometric objects and references to other cells.

Parameters:name – The name of the cell.
add(element, *args, **kwargs)[source]

Add a new element or list of elements to this cell.

Parameters:element – The element or list of elements to be inserted in this cell.

A Cell are added by implicitly creating a CellReference, they can be accompanied by all the arguments available when explicity using CellReference. To add a Cell as an array it is necessary to first create the CellArray and then add that.

area(by_layer=False)[source]

Calculate the total area of the elements on this cell, including cell references and arrays.

Parameters:by_layer – If True, the return value is a dictionary with the areas of each individual layer.
Returns:Area of this cell.
artist()[source]

Return a list of matplotlib artists for drawing this object

bounding_box[source]

Returns the bounding box for this cell.

Returns:Bounding box of this cell [[x_min, y_min], [x_max, y_max]], or None if the cell is empty.
copy(name=None, suffix=None)[source]

Creates a deepcopy of this cell.

This makes a deep copy, all elements are recursively duplicated

Parameters:
  • name – The name of the new cell.
  • suffix – A suffix to add to the end of the name of every subcell
Returns:

The new copy of this cell.

elements[source]
flatten()[source]

Returns a list of copies of the elements of this cell with References converted to Paths and Boundaries.

Returns:A flattened list of copies of this cell’s contents.
A flattened version of this cell can be reconstructed with::
flat_cell = Cell(‘FLAT’) flat_cell.add(deep_cell.flatten())
get_dependencies(include_elements=False)[source]

Returns a list of all cells included as references by this cell.

Subcells are checked recursively.

Parameters:include_elements – If true returns a complete list of all elements in the heirarchy
Returns:List of the cells referenced by this cell.
get_layers()[source]

Returns a list of layers in this cell.

Returns:List of the layers used in this cell.
objects[source]

Get all elements excluding any references.

prune()[source]

Remove any subcells that contain no elements.

Returns:True if the cell and all of its subcells contain no elements
references[source]

Get all references in this cell.

show()

Display the object

Returns:the display Axes.
to_gds(multiplier, duplicates=[])[source]

Convert this cell to a GDSII structure.

Parameters:
  • multiplier – A number that multiplies all dimensions written in the GDSII structure.
  • uniquify – If True saves the cell reference according to its uniquified name.
Returns:

The GDSII binary string that represents this cell.

unique_name[source]
class gdsCAD.core.CellArray(ref_cell, cols, rows, spacing, origin=(0, 0), rotation=None, magnification=None, x_reflection=False)[source]

Bases: gdsCAD.core.ReferenceBase

Multiple references to an existing cell in a grid arrangement.

Parameters:
  • ref_cell – The referenced cell.
  • cols – Number of columns in the array.
  • rows – Number of rows in the array.
  • spacing – The distance between copies within the array. This can be either a 2-tuple or a pair of 2-tuples. The former (n,m) is interpreted as ((n,0), (0,m))
  • origin – Position where the cell is inserted.
  • rotation – Angle of rotation of the reference (in degrees).
  • magnification – Magnification factor for the reference.
  • x_reflection – If True, the reference is reflected parallel to the x direction before being rotated.

Note

This is a direct equivalent to the AREF element found in the GDSII specification.

area(by_layer=False)[source]

Calculate the total area of the referenced cell with the magnification factor included.

Parameters:by_layer – If True, the return value is a dictionary with the areas of each individual layer.
Returns:Area of this cell.
artist()[source]

Return a list of matplotlib artists for drawing this object

Warning

Does not yet handle x_reflections correctly

bounding_box[source]

Returns the bounding box for this reference.

Currently does not handle rotated references

Returns:Bounding box of this cell [[x_min, y_min], [x_max, y_max]], or None if the cell is empty.
copy(suffix=None)[source]
flatten()[source]

Return reference as a flattened list of elements.

get_dependencies(include_elements=False)
rotate(angle)

Rotate this object by angle

Parameters:angle – the angle by which to rotate the cell
Returns:self
scale(k)

Scale this object by factor k

Parameters:k – the factor by which to scale the cell
Returns:self
to_gds(multiplier, duplicates=[])[source]

Convert this object to a GDSII element.

Parameters:
  • multiplier – A number that multiplies all dimensions written in the GDSII element.
  • uniquify – If True saves the cell reference according to its uniquified name.
Returns:

The GDSII binary string that represents this object.

translate(displacement)

Translate this object by displacement

Parameters:displacement – the vector by which to move the cell
Returns:self
class gdsCAD.core.CellReference(ref_cell, origin=(0, 0), rotation=None, magnification=None, x_reflection=False)[source]

Bases: gdsCAD.core.ReferenceBase

Simple reference to an existing cell.

Parameters:
  • ref_cell – The referenced cell.
  • origin – Position where the reference is inserted.
  • rotation – Angle of rotation of the reference (in degrees).
  • magnification – Magnification factor for the reference.
  • x_reflection – If True, the reference is reflected parallel to the x direction before being rotated.

Note

This is a direct equivalent to the SREF element found in the GDSII specification.

area(by_layer=False)[source]

Calculate the total area of the referenced cell with the magnification factor included.

Parameters:by_layer – If True, the return value is a dictionary with the areas of each individual layer.
Returns:Area of this cell.
artist()[source]

Return a list of matplotlib artists for drawing this object

Warning

Does not yet handle x_reflections correctly

bounding_box[source]

Returns the bounding box for this reference.

Currently does not handle rotated references

Returns:Bounding box of this cell [[x_min, y_min], [x_max, y_max]], or None if the cell is empty.
copy(suffix=None)
flatten()[source]

Return reference as a flattened list of elements.

get_dependencies(include_elements=False)
rotate(angle)

Rotate this object by angle

Parameters:angle – the angle by which to rotate the cell
Returns:self
scale(k)

Scale this object by factor k

Parameters:k – the factor by which to scale the cell
Returns:self
to_gds(multiplier, duplicates=[])[source]

Convert this object to a GDSII element.

Parameters:
  • multiplier – A number that multiplies all dimensions written in the GDSII element.
  • uniquify – If True saves the cell reference according to its uniquified name.
Returns:

The GDSII binary string that represents this object.

translate(displacement)

Translate this object by displacement

Parameters:displacement – the vector by which to move the cell
Returns:self
gdsCAD.core.DxfImport(fname, scale=1.0)[source]

Import artwork from a DXF File.

Parameters:
  • fname – the DXF file
  • scale – the scale factor for the drawing dimensions

Currently only supports POLYLINE and LINE entities which are returned as a list. Closed POLYLINES are interpreted as Boundaries, LINES and open POLYLINES are interpreted as Paths. DxfImport will attempt to cast layer name strings to integers. If it fails the default layer will be used.

class gdsCAD.core.ElementBase(points, dtype=<type 'numpy.float32'>)[source]

Bases: object

Base class for geometric elements. Other drawing elements derive from this.

bounding_box[source]

Return the bounding box containing the polygon

copy(suffix=None)[source]

Make a copy of this element.

Parameters:suffix – Ignored
points[source]
reflect(axis, origin=(0, 0))[source]

Reflect this object in the x or y axis

Parameters:
  • axis – ‘x’ or ‘y’ indicating which axis in which to make the refln
  • origin – A point which will remain invariant on reflection
Returns:

self

Optional origin can be a 2D vector or ‘COM’ indicating that scaling should be made about the pts centre of mass.

The transformation acts in place.

rotate(angle, center=(0, 0))[source]

Rotate this object.

Parameters:
  • angle – The angle of rotation (in deg).
  • center – Center point for the rotation.
Returns:

self

The optional center point can be specified by a 2D vector or the string ‘com’ for center of mass.

The transformation acts in place.

scale(k, origin=(0, 0))[source]

Scale this object by the factor k

Parameters:
  • k – the value by which to scale the object
  • origin – the point about which to make the scaling
Returns:

self

The factor k can be a scalar or 2D vector allowing non-uniform scaling. Optional origin can be a 2D vector or ‘COM’ indicating that scaling should be made about the pts centre of mass.

The transformation acts in place.

translate(displacement)[source]

Translate this object.

Parameters:displacment – The vector by which to displace this object.
Returns:self

The transformation acts in place.

class gdsCAD.core.Elements(obj=None, layer=None, datatype=None, obj_type=None, **kwargs)[source]

Bases: object

A list-like collection of Boundary and/or Path objects.

:param obj : List containing the coordinates of the vertices of each polygon.
Or a list of already defined elements.
Parameters:
  • layer – The GDSII layer number for this element. Defaults to layer of 1st object, or core.default_layer.
  • datatype – The GDSII datatype for this element (between 0 and 255).
  • obj_type – Specify whether to interpret the list of point arrays as boundaries, or paths

The class Elements is intended to simplify geometric transformations on several drawing elements at once. There is no GDSII equivalent. Elements is not a substitute for Cell. In particular, multiple Elements added to a design cannot be added by reference. Each instance will be seperately written to the file.

There are many different ways of initializing an Elements list. The simplest is to call it with no parameters i.e. Elements() and then add elements. One list of elements can be added to another. The individual objects in the first Elements list will be added to the second so that the list is flat.

All elements in the list share the same layer and datatype. Changing the layer or datatype for the Elements list changes it for all contained elements

Elements can be indexed using simple indexing:

print elist[1]

Elements can be used as an iterator:

for el in elist:
    print el

Examples:

square_pts=[[0,0, [1,0], [1,1], [0,1]]]        
triangle_pts=[[1,0], [2,0], [2,2]]

square=Polygon(square_pts)
triangle=Path(triangle_pts, width=0.5)

# Create an empty list and fill it later
elist=Elements()
elist.add(square)
elist.add(triangle)

# Create a filled square and an unfilled triangle
elist=Elements([square, triangle])

# Create two filled boundaries from a list of points
elist=Elements([square_pts, triangle_pts])

# Create two unfilled paths from a list of points
elist=Elements([square_pts, triangle_pts], obj_type='path', width=0.5)

# Create a filled square and an unfilled triangle
elist=Elements([square_pts, triangle_pts], obj_type=['boundary', 'path'])
add(obj)[source]

Add a new element or list of elements to this list.

Parameters:element – The element to be inserted in this list.
area()[source]

Calculate the area of the elements.

artist(color=None)[source]

Return a list of matplotlib artists for drawing this object

bounding_box[source]

Return the bounding box containing all Elements

copy(suffix=None)[source]

Make a copy of the object and all contained elements

datatype[source]

Get the datatype

layer[source]

Get the layer

reflect(axis, origin=(0, 0))[source]

Reflect this object in the x or y axis

Parameters:
  • axis – ‘x’ or ‘y’ indcating which axis in which to make the refln
  • origin – A point which will remain invariant on reflection
Returns:

self

Optional origin can be a 2D vector or ‘COM’ indicating that scaling should be made about the pts centre of mass.

The transformation acts in place.

rotate(angle, center=(0, 0))[source]

Rotate this object.

Parameters:
  • angle – The angle of rotation (in deg).
  • center – Center point for the rotation.
Returns:

self

The transformation acts in place.

scale(k, origin=(0, 0))[source]

Scale this object by the factor k

Parameters:
  • k – the value by which to scale the object
  • origin – the point about which to make the scaling
Returns:

self

The factor k can be a scalar or 2D vector allowing non-uniform scaling. Optional origin can be a 2D vector or ‘COM’ indicating that scaling should be made about the pts centre of mass.

The transformation acts in place.

show()

Display the object

Returns:the display Axes.
to_gds(multiplier)[source]

Convert this object to a series of GDSII elements.

Parameters:multiplier – A number that multiplies all dimensions written in the GDSII elements.
Returns:The GDSII binary string that represents this object.
translate(displacement)[source]

Translate this object.

Parameters:displacement – The vector by which to displace all the elements.
Returns:self

The transformation acts in place.

gdsCAD.core.GdsImport(infile, rename={}, layers={}, datatypes={}, verbose=True)[source]

Import a new Layout from a GDSII stream file.

Parameters:
  • infile – GDSII stream file (or path) to be imported. It must be opened for reading in binary format.
  • rename – Dictionary used to rename the imported cells. Keys and values must be strings.
  • layers – Dictionary used to convert the layers in the imported cells. Keys and values must be integers.
  • datatypes – Dictionary used to convert the datatypes in the imported cells. Keys and values must be integers.
  • verbose – If False, suppresses warnings about unsupported elements in the imported file.
Returns:

A :class:Layout containing the imported gds file.

Notes:

Not all features from the GDSII specification are currently supported.
A warning will be produced if any unsuported features are found in the
imported file.

Examples:

layout = core.GdsImport('sample.gds')
class gdsCAD.core.Layout(name='library', unit=1e-06, precision=1e-09)[source]

Bases: dict

A layout object

Parameters:
  • name – Name of the GDSII library.
  • unit – Unit size for the objects in the library (in meters).
  • precision – Precision for the dimensions of the objects in the library (in meters).

A layout is a dict based collection of Cells. Cells can be accessed by their name:

l=gdsCAD.core.Layout('layout')
l.add(top_cell)
print l[top_cell.name]

The dimensions actually written on the GDSII file will be the dimensions of the objects created times the ratio unit/precision. For example, if a circle with radius 1.5 is created and we set unit=1.0e-6 (1 um) and precision=1.0e-9 (1 nm), the radius of the circle will be 1.5 um and the GDSII file will contain the dimension 1500 nm.

Note

This is a direct equivalent to the Library element found in the GDSII specification.

add(cell)[source]

Add a new cell to this layout.

Parameters:element – The Cell to be inserted in this Layout.
artist()[source]

Return a list of matplotlib artists for drawing this object

Returns artists for every top level cell in this layout

bounding_box[source]

Returns the bounding box for this layout.

Returns:Bounding box of this cell [[x_min, y_min], [x_max, y_max]], or None if the cell is empty.
clear() → None. Remove all items from D.
copy()[source]

Creates a deep copy of this Layout.

Returns:The new copy of this layout.

This makes a deep copy, all elements are recursively duplicated

static fromkeys(S[, v]) → New dict with keys from S and values equal to v.

v defaults to None.

get(k[, d]) → D[k] if k in D, else d. d defaults to None.
get_dependencies()[source]

Returns a list of all cells included in this layout.

Subcells are checked recursively

Parameters:out – List of the cells referenced by this cell.
has_key(k) → True if D has a key k, else False
items() → list of D's (key, value) pairs, as 2-tuples
iteritems() → an iterator over the (key, value) items of D
iterkeys() → an iterator over the keys of D
itervalues() → an iterator over the values of D
keys() → list of D's keys
pop(k[, d]) → v, remove specified key and return the corresponding value.

If key is not found, d is returned if given, otherwise KeyError is raised

popitem() → (k, v), remove and return some (key, value) pair as a

2-tuple; but raise KeyError if D is empty.

save(outfile)[source]

Output a list of cells as a GDSII stream library.

Cell names are checked for uniqueness. If there are duplicate cell names then a unique ID is appended to the cell name to force uniqueness.

Parameters:outfile – The file (or path) where the GDSII stream will be written. It must be opened for writing operations in binary format.
setdefault(k[, d]) → D.get(k,d), also set D[k]=d if k not in D
show()

Display the object

Returns:the display Axes.
top_level()[source]

Output the top level cells from the GDSII layout. Top level cells are those that are not referenced by any other cells.

Returns:List of top level cells.
update([E, ]**F) → None. Update D from dict/iterable E and F.

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() → list of D's values
viewitems() → a set-like object providing a view on D's items
viewkeys() → a set-like object providing a view on D's keys
viewvalues() → an object providing a view on D's values
class gdsCAD.core.Path(points, width=1.0, layer=None, datatype=None, pathtype=0, verbose=False, dtype=<type 'numpy.float32'>)[source]

Bases: gdsCAD.core.ElementBase

An unfilled, unclosed polygonal line of fixed width.

Parameters:
  • points – Coordinates of the vertices of the polygon.
  • width – The width of the line
  • layer – The GDSII layer number for this element. Defaults to core.default_layer.
  • datatype – The GDSII datatype for this element (between 0 and 255).
  • pathtype – The endpoint style

Note

This is a direct equivalent to the Path element found in the GDSII specification.

Paths are not automatically closed. The official GDSII specification supports only a maximum of 199 vertices per path.

The style of endcaps is specificed by pathtype:

   
0 Square ended paths
1 Round ended
2 Square ended, extended 1/2 width
4 Variable length extensions

Examples:

arrow_pts = [(0, 40), (15, 40), (10, 50)]
arrow = gdsCAD.core.Path(arrow_pts)
myCell.add(arrow)
area()[source]

Calculates the approximate area of the element.

This is only an estimate. It does not correctly deal with overlaps at corners.

artist(color=None)[source]

Return a list of matplotlib artists to draw this object

Warning

Path endpoints are not rendered correctly. They always display as half-circles.

Paths are rendered by first converting them to a shapely polygon and then converting this to a descartes polgyonpatch. This generates a path whose line width scales with the drawing size. Aside from being convoluted it means that path ends always render as half-circles.

bounding_box

Return the bounding box containing the polygon

copy(suffix=None)

Make a copy of this element.

Parameters:suffix – Ignored
points
reflect(axis, origin=(0, 0))

Reflect this object in the x or y axis

Parameters:
  • axis – ‘x’ or ‘y’ indicating which axis in which to make the refln
  • origin – A point which will remain invariant on reflection
Returns:

self

Optional origin can be a 2D vector or ‘COM’ indicating that scaling should be made about the pts centre of mass.

The transformation acts in place.

rotate(angle, center=(0, 0))

Rotate this object.

Parameters:
  • angle – The angle of rotation (in deg).
  • center – Center point for the rotation.
Returns:

self

The optional center point can be specified by a 2D vector or the string ‘com’ for center of mass.

The transformation acts in place.

scale(k, origin=(0, 0))

Scale this object by the factor k

Parameters:
  • k – the value by which to scale the object
  • origin – the point about which to make the scaling
Returns:

self

The factor k can be a scalar or 2D vector allowing non-uniform scaling. Optional origin can be a 2D vector or ‘COM’ indicating that scaling should be made about the pts centre of mass.

The transformation acts in place.

show()

Display the object

Returns:the display Axes.
to_boundary()[source]

Convert this Path to a Boundary.

Open paths will be closed as boundaries.

to_gds(multiplier)[source]

Convert this object to a GDSII element.

:param multiplier : A number that multiplies all dimensions written
in the GDSII element.
Returns:The GDSII binary string that represents this object.
translate(displacement)

Translate this object.

Parameters:displacment – The vector by which to displace this object.
Returns:self

The transformation acts in place.

class gdsCAD.core.ReferenceBase[source]

Base class for cell references

copy(suffix=None)[source]
get_dependencies(include_elements=False)[source]
rotate(angle)[source]

Rotate this object by angle

Parameters:angle – the angle by which to rotate the cell
Returns:self
scale(k)[source]

Scale this object by factor k

Parameters:k – the factor by which to scale the cell
Returns:self
translate(displacement)[source]

Translate this object by displacement

Parameters:displacement – the vector by which to move the cell
Returns:self
class gdsCAD.core.Text(text, position, anchor='o', rotation=None, magnification=None, layer=None, datatype=None, x_reflection=None, dtype=<type 'numpy.float32'>)[source]

Bases: gdsCAD.core.ElementBase

A non-printing text label

Parameters:
  • text – The text of this label.
  • position – Text anchor position.
  • anchor – Position of the anchor relative to the text.
  • rotation – Angle of rotation of the label (in degrees).
  • magnification – Magnification factor for the label.
  • layer – The GDSII layer number for this element. Defaults to core.default_layer.
  • datatype – The GDSII text type for the label (between 0 and 63).

Note

This is a direct equivalent to the Text element found in the GDSII specification.

Text that can be used to label parts of the geometry or display messages. The text does not create additional geometry, it’s meant for display and labeling purposes only.

Examples:

txt = gdspy.Text('Sample label', (10, 0), 'sw')
myCell.add(txt)
area()[source]

The area of the element.

For text this is always 0, since it is non-printing.

artist()[source]

Return a list of matplotlib artists for drawing this object

Warning

Does not properly handle rotations or scaling

bounding_box[source]

Return the bounding box containing the Text

It’s not really clear how this should work, but for the moment it only returns the point of insertion

copy(suffix=None)

Make a copy of this element.

Parameters:suffix – Ignored
points
reflect(axis, origin=(0, 0))[source]

Reflect this object in the x or y axis

Parameters:
  • axis – ‘x’ or ‘y’ indcating which axis in which to make the refln
  • origin – A point which will remain invariant on reflection
Returns:

self

Optional origin can be a 2D vector or ‘COM’ indicating that scaling should be made about the pts centre of mass.

The transformation acts in place.

rotate(angle, center=(0, 0))[source]

Rotate this object.

Parameters:
  • angle – The angle of rotation (in deg).
  • center – Center point for the rotation.
Returns:

self

The transformation acts in place.

scale(k, origin=(0, 0))

Scale this object by the factor k

Parameters:
  • k – the value by which to scale the object
  • origin – the point about which to make the scaling
Returns:

self

The factor k can be a scalar or 2D vector allowing non-uniform scaling. Optional origin can be a 2D vector or ‘COM’ indicating that scaling should be made about the pts centre of mass.

The transformation acts in place.

show()

Display the object

Returns:the display Axes.
to_gds(multiplier)[source]

Convert this text to a GDSII element.

Parameters:multiplier – A number that multiplies all dimensions written in the GDSII structure.
Returns:The GDSII binary string that represents this label.
translate(displacement)

Translate this object.

Parameters:displacment – The vector by which to displace this object.
Returns:self

The transformation acts in place.