How to use the gdspy.copy function in gdspy

To help you get started, we’ve selected a few gdspy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heitzmann / gdspy / tests / polygonset.py View on Github external
(0, 0),
                (-1, 0),
                (0, -1),
                (0.5, -0.5),
                (1, 0),
                (1, 1),
                (4, -1),
                (1, 3),
                (1, 2),
                (0, 1),
            ],
            [(2, -1), (3, -1), (2.5, -2)],
        ]
    )
    orig.datatypes = [0, 1]
    p = gdspy.copy(orig, 0, 5)
    p.layers = [1, 1]
    p.fillet(0.3, max_points=0)
    cell.add(p)
    p = gdspy.copy(orig, 5, 5)
    p.layers = [2, 2]
    p.fillet(
        [0.3, 0.2, 0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.4, 0.1, 0.2, 0], max_points=0
    )
    cell.add(p)
    p = gdspy.copy(orig, 5, 0)
    p.layers = [3, 3]
    p.fillet(
        [[0.1, 0.1, 0.4, 0, 0.4, 0.1, 0.1, 0.4, 0.4, 0.1], [0.2, 0.2, 0.5]],
        max_points=0,
    )
    cell.add(p)
github heitzmann / gdspy / tools / maketestgds.py View on Github external
(1, 0),
            (1, 1),
            (4, -1),
            (1, 3),
            (1, 2),
            (0, 1),
        ],
        [(2, -1), (3, -1), (2.5, -2)],
    ]
)
orig.datatypes = [0, 1]
p = gdspy.copy(orig, 0, 5)
p.layers = [1, 1]
p.fillet(0.3, max_points=0)
cell.add(p)
p = gdspy.copy(orig, 5, 5)
p.layers = [2, 2]
p.fillet([0.3, 0.2, 0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.4, 0.1, 0.2, 0], max_points=0)
cell.add(p)
p = gdspy.copy(orig, 5, 0)
p.layers = [3, 3]
p.fillet(
    [[0.1, 0.1, 0.4, 0, 0.4, 0.1, 0.1, 0.4, 0.4, 0.1], [0.2, 0.2, 0.5]], max_points=0
)
cell.add(p)
p = gdspy.copy(orig, 0, 0)
p.layers = [4, 4]
p.fillet([0.8, [10.0, 10.0, 20.0]], max_points=199, precision=1e-6)
cell.add(p)


### FlexPath
github heitzmann / gdspy / tests / polygonset.py View on Github external
],
            [(2, -1), (3, -1), (2.5, -2)],
        ]
    )
    orig.datatypes = [0, 1]
    p = gdspy.copy(orig, 0, 5)
    p.layers = [1, 1]
    p.fillet(0.3, max_points=0)
    cell.add(p)
    p = gdspy.copy(orig, 5, 5)
    p.layers = [2, 2]
    p.fillet(
        [0.3, 0.2, 0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.4, 0.1, 0.2, 0], max_points=0
    )
    cell.add(p)
    p = gdspy.copy(orig, 5, 0)
    p.layers = [3, 3]
    p.fillet(
        [[0.1, 0.1, 0.4, 0, 0.4, 0.1, 0.1, 0.4, 0.4, 0.1], [0.2, 0.2, 0.5]],
        max_points=0,
    )
    cell.add(p)
    p = gdspy.PolygonSet(
        [
            [
                (0, 0),
                (0, 0),
                (-1, 0),
                (0, -1),
                (0.5, -0.5),
                (1, 0),
                (1, 0),
github heitzmann / gdspy / tests / functions.py View on Github external
assert set(q.polygons[0][:, 0]) == {1, 2}
    assert set(q.polygons[0][:, 1]) == {-1, 0}
    assert set(p.polygons[1][:, 0]) == {2, 3}
    assert set(p.polygons[1][:, 1]) == {2, 3}
    assert set(q.polygons[1][:, 0]) == {3, 4}
    assert set(q.polygons[1][:, 1]) == {1, 2}
    l = gdspy.Label("text", (0, 1))
    m = gdspy.copy(l, -1, 1)
    assert l.position[0] == 0 and l.position[1] == 1
    assert m.position[0] == -1 and m.position[1] == 2
    c = gdspy.CellReference("empty", (0, 1), ignore_missing=True)
    d = gdspy.copy(c, -1, 1)
    assert c.origin == (0, 1)
    assert d.origin == (-1, 2)
    c = gdspy.CellArray("empty", 2, 3, (1, 0), (0, 1), ignore_missing=True)
    d = gdspy.copy(c, -1, 1)
    assert c.origin == (0, 1)
    assert d.origin == (-1, 2)
github heitzmann / gdspy / tools / maketestgds.py View on Github external
orig.datatypes = [0, 1]
p = gdspy.copy(orig, 0, 5)
p.layers = [1, 1]
p.fillet(0.3, max_points=0)
cell.add(p)
p = gdspy.copy(orig, 5, 5)
p.layers = [2, 2]
p.fillet([0.3, 0.2, 0.1, 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.4, 0.1, 0.2, 0], max_points=0)
cell.add(p)
p = gdspy.copy(orig, 5, 0)
p.layers = [3, 3]
p.fillet(
    [[0.1, 0.1, 0.4, 0, 0.4, 0.1, 0.1, 0.4, 0.4, 0.1], [0.2, 0.2, 0.5]], max_points=0
)
cell.add(p)
p = gdspy.copy(orig, 0, 0)
p.layers = [4, 4]
p.fillet([0.8, [10.0, 10.0, 20.0]], max_points=199, precision=1e-6)
cell.add(p)


### FlexPath


def broken(p0, v0, p1, v1, p2, w):
    den = v1[1] * v0[0] - v1[0] * v0[1]
    lim = 1e-12 * (v0[0] ** 2 + v0[1] ** 2) * (v1[0] ** 2 + v1[1] ** 2)
    if den ** 2 < lim:
        u0 = u1 = 0
        p = 0.5 * (p0 + p1)
    else:
        dx = p1[0] - p0[0]
github BerkeleyPhotonicsGenerator / BPG / gdspy / examples / tutorial.py View on Github external
# Translatable objects can also be copied & translated in the same way.
rect2 = gdspy.Rectangle((80, 0), (81, 1), 2)
rect3 = gdspy.copy(rect2, 0, 3)
trans_cell.add(rect2)
trans_cell.add(rect3)

# Reference Cells are also translatable, and thus copyable.
ref1 = gdspy.CellReference(poly_cell, (25, 0), rotation=180)
ref2 = gdspy.copy(ref1, 30, 30)
trans_cell.add(ref1)
trans_cell.add(ref2)

# Same goes for Labels & Text
text1 = gdspy.Text(
    'Created with gsdpy ' + gdspy.__version__, 7, (-7, -35), layer=6)
text2 = gdspy.copy(text1, 0, -20)
label1 = gdspy.Label(
    'Created with gdspy ' + gdspy.__version__, (-7, -36), 'nw', layer=6)
label2 = gdspy.copy(label1, 0, -20)
trans_cell.add(text1)
trans_cell.add(text2)
trans_cell.add(label1)
trans_cell.add(label2)

# ------------------------------------------------------------------ #
#      OUTPUT
# ------------------------------------------------------------------ #

# Output the layout to a GDSII file (default to all created cells).
# Set the units we used to micrometers and the precision to nanometers.
gdspy.write_gds('tutorial.gds', unit=1.0e-6, precision=1.0e-9)
github BerkeleyPhotonicsGenerator / BPG / gdspy / examples / tutorial.py View on Github external
'text TYPE 3', (-7, -42), 'se', layer=6, texttype=3))
# ------------------------------------------------------------------ #
#      Translation
# ------------------------------------------------------------------ #

trans_cell = gdspy.Cell('TRANS')

# Any geometric object can be translated by providing the distance to
# translate in the x-direction and y-direction:  translate(dx, dy)
rect1 = gdspy.Rectangle((80, 0), (81, 1), 1)
rect1.translate(2, 0)
trans_cell.add(rect1)

# Translatable objects can also be copied & translated in the same way.
rect2 = gdspy.Rectangle((80, 0), (81, 1), 2)
rect3 = gdspy.copy(rect2, 0, 3)
trans_cell.add(rect2)
trans_cell.add(rect3)

# Reference Cells are also translatable, and thus copyable.
ref1 = gdspy.CellReference(poly_cell, (25, 0), rotation=180)
ref2 = gdspy.copy(ref1, 30, 30)
trans_cell.add(ref1)
trans_cell.add(ref2)

# Same goes for Labels & Text
text1 = gdspy.Text(
    'Created with gsdpy ' + gdspy.__version__, 7, (-7, -35), layer=6)
text2 = gdspy.copy(text1, 0, -20)
label1 = gdspy.Label(
    'Created with gdspy ' + gdspy.__version__, (-7, -36), 'nw', layer=6)
label2 = gdspy.copy(label1, 0, -20)
github heitzmann / gdspy / docs / _static / photonics.py View on Github external
[(input_gap * i, taper_len + bus_len)],
            width=[small_margin, small_margin],
            offset=small_margin + width,
            gdsii_path=True,
        )
        path.segment((0, 600 - bus_len - bend_radius - wg_gap * i), relative=True)
        path.turn(bend_radius, "r")
        path.segment((io_gap - 2 * bend_radius, 0), relative=True)
        path.turn(bend_radius, "l")
        path.segment((0, 300 - bend_radius + wg_gap * i), relative=True)
        c.add(path)
        dx = width / 2 + gap
        c.add(
            gdspy.boolean(
                gdspy.boolean(
                    ring_bus, gdspy.copy(ring_margin, dx, 300), "or", precision=1e-4
                ),
                gdspy.copy(ring_hole, dx, 300),
                "not",
                precision=1e-4,
            ).translate(input_gap * i, 0)
        )
    c.add(gdspy.CellArray(taper, len(ring_gaps), 1, (input_gap, 0), (0, 0)))
    c.add(
        gdspy.CellArray(
            grat, len(ring_gaps), 1, (input_gap, 0), (io_gap, 900 + taper_len)
        )
    )

    # Save to a gds file and check out the output
    gdspy.write_gds("photonics.gds")
    gdspy.LayoutViewer()
github heitzmann / gdspy / examples / tutorial.py View on Github external
# ------------------------------------------------------------------ #
#      TRANSLATION AND REFLECTION
# ------------------------------------------------------------------ #

trans_cell = gdspy.Cell('TRANS')

# Any geometric object can be translated by providing the distance to
# translate in the x-direction and y-direction:  translate(dx, dy)
rect1 = gdspy.Rectangle((80, 0), (81, 1), 1)
rect1.translate(2, 0)
trans_cell.add(rect1)

# Translatable objects can also be copied & translated in the same way.
rect2 = gdspy.Rectangle((80, 0), (81, 1), 2)
rect3 = gdspy.copy(rect2, 0, 3)
trans_cell.add(rect2)
trans_cell.add(rect3)

# Reference Cells are also translatable, and thus copyable.
ref1 = gdspy.CellReference(poly_cell, (25, 0), rotation=180)
ref2 = gdspy.copy(ref1, 30, 30)
trans_cell.add(ref1)
trans_cell.add(ref2)

# Same goes for Labels & Text
text1 = gdspy.Text('Created with gdspy ' + gdspy.__version__, 7, (-7, -35), layer=6)
text2 = gdspy.copy(text1, 0, -20)
label1 = gdspy.Label('Created with gdspy ' + gdspy.__version__, (-7, -36), 'nw', layer=6)
label2 = gdspy.copy(label1, 0, -20)
trans_cell.add(text1)
trans_cell.add(text2)