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.
These can all be added to a cell. Only Boundary and Path are drawing elements.
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
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. |
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.
These can all be added to a cell. Only Boundary and Path are drawing elements.
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
Bases: gdsCAD.core.ElementBase
A filled, closed polygonal geometric object.
Parameters: |
|
---|
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.
Calculates the area of the element.
Assumes that the Boundary respects the GDSII requirement that the path be simple and closed.
Return the bounding box containing the polygon
Make a copy of this element.
Parameters: | suffix – Ignored |
---|
Reflect this object in the x or y axis
Parameters: |
|
---|---|
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 this object.
Parameters: |
|
---|---|
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 this object by the factor k
Parameters: |
|
---|---|
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.
Display the object
Returns: | the display Axes. |
---|
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. |
Convert this Boundary to a Path
Parameters: |
|
---|
Translate this object.
Parameters: | displacment – The vector by which to displace this object. |
---|---|
Returns: | self |
The transformation acts in place.
Bases: object
Collection of elements, both geometric objects and references to other cells.
Parameters: | name – The name of the cell. |
---|
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.
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. |
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. |
---|
Creates a deepcopy of this cell.
This makes a deep copy, all elements are recursively duplicated
Parameters: |
|
---|---|
Returns: | The new copy of this cell. |
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. |
---|
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. |
Returns a list of layers in this cell.
Returns: | List of the layers used in this cell. |
---|
Remove any subcells that contain no elements.
Returns: | True if the cell and all of its subcells contain no elements |
---|
Display the object
Returns: | the display Axes. |
---|
Convert this cell to a GDSII structure.
Parameters: |
|
---|---|
Returns: | The GDSII binary string that represents this cell. |
Bases: gdsCAD.core.ReferenceBase
Multiple references to an existing cell in a grid arrangement.
Parameters: |
|
---|
Note
This is a direct equivalent to the AREF element found in the GDSII specification.
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. |
Return a list of matplotlib artists for drawing this object
Warning
Does not yet handle x_reflections correctly
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. |
---|
Rotate this object by angle
Parameters: | angle – the angle by which to rotate the cell |
---|---|
Returns: | self |
Scale this object by factor k
Parameters: | k – the factor by which to scale the cell |
---|---|
Returns: | self |
Convert this object to a GDSII element.
Parameters: |
|
---|---|
Returns: | The GDSII binary string that represents this object. |
Translate this object by displacement
Parameters: | displacement – the vector by which to move the cell |
---|---|
Returns: | self |
Bases: gdsCAD.core.ReferenceBase
Simple reference to an existing cell.
Parameters: |
|
---|
Note
This is a direct equivalent to the SREF element found in the GDSII specification.
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. |
Return a list of matplotlib artists for drawing this object
Warning
Does not yet handle x_reflections correctly
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. |
---|
Rotate this object by angle
Parameters: | angle – the angle by which to rotate the cell |
---|---|
Returns: | self |
Scale this object by factor k
Parameters: | k – the factor by which to scale the cell |
---|---|
Returns: | self |
Convert this object to a GDSII element.
Parameters: |
|
---|---|
Returns: | The GDSII binary string that represents this object. |
Translate this object by displacement
Parameters: | displacement – the vector by which to move the cell |
---|---|
Returns: | self |
Import artwork from a DXF File.
Parameters: |
|
---|
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.
Bases: object
Base class for geometric elements. Other drawing elements derive from this.
Reflect this object in the x or y axis
Parameters: |
|
---|---|
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 this object.
Parameters: |
|
---|---|
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 this object by the factor k
Parameters: |
|
---|---|
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.
Bases: object
A list-like collection of Boundary and/or Path objects.
Parameters: |
|
---|
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 a new element or list of elements to this list.
Parameters: | element – The element to be inserted in this list. |
---|
Reflect this object in the x or y axis
Parameters: |
|
---|---|
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 this object.
Parameters: |
|
---|---|
Returns: | self |
The transformation acts in place.
Scale this object by the factor k
Parameters: |
|
---|---|
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.
Display the object
Returns: | the display Axes. |
---|
Import a new Layout from a GDSII stream file.
Parameters: |
|
---|---|
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')
Bases: dict
A layout object
Parameters: |
|
---|
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 a new cell to this layout.
Parameters: | element – The Cell to be inserted in this Layout. |
---|
Return a list of matplotlib artists for drawing this object
Returns artists for every top level cell in this layout
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. |
---|
Creates a deep copy of this Layout.
Returns: | The new copy of this layout. |
---|
This makes a deep copy, all elements are recursively duplicated
v defaults to None.
Returns a list of all cells included in this layout.
Subcells are checked recursively
Parameters: | out – List of the cells referenced by this cell. |
---|
If key is not found, d is returned if given, otherwise KeyError is raised
2-tuple; but raise KeyError if D is empty.
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. |
---|
Display the object
Returns: | the display Axes. |
---|
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. |
---|
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]
Bases: gdsCAD.core.ElementBase
An unfilled, unclosed polygonal line of fixed width.
Parameters: |
|
---|
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)
Calculates the approximate area of the element.
This is only an estimate. It does not correctly deal with overlaps at corners.
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.
Return the bounding box containing the polygon
Make a copy of this element.
Parameters: | suffix – Ignored |
---|
Reflect this object in the x or y axis
Parameters: |
|
---|---|
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 this object.
Parameters: |
|
---|---|
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 this object by the factor k
Parameters: |
|
---|---|
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.
Display the object
Returns: | the display Axes. |
---|
Convert this object to a GDSII element.
Returns: | The GDSII binary string that represents this object. |
---|
Translate this object.
Parameters: | displacment – The vector by which to displace this object. |
---|---|
Returns: | self |
The transformation acts in place.
Base class for cell references
Rotate this object by angle
Parameters: | angle – the angle by which to rotate the cell |
---|---|
Returns: | self |
Bases: gdsCAD.core.ElementBase
A non-printing text label
Parameters: |
|
---|
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)
Return a list of matplotlib artists for drawing this object
Warning
Does not properly handle rotations or scaling
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
Make a copy of this element.
Parameters: | suffix – Ignored |
---|
Reflect this object in the x or y axis
Parameters: |
|
---|---|
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 this object.
Parameters: |
|
---|---|
Returns: | self |
The transformation acts in place.
Scale this object by the factor k
Parameters: |
|
---|---|
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.
Display the object
Returns: | the display Axes. |
---|
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 this object.
Parameters: | displacment – The vector by which to displace this object. |
---|---|
Returns: | self |
The transformation acts in place.