Coder Social home page Coder Social logo

Comments (2)

heitzmann avatar heitzmann commented on July 19, 2024

Hello @Engi4, if your goal is only to merge different files that may have similar cell names, the simplest solution is to use the rename argument in gds_import.

Something around these lines (I modified the example you presented in #16):

import gdspy

operations = {
    'Dcsfq.gds': {'origin': (150, 0)},
    'Conf2.gds': {'origin': (0, 0)},
    'Tff4b.gds': {'origin': (225, -150), 'rotation': 90}
}

ref_cell = gdspy.Cell('TRANSLATED')

for i, file_name in enumerate(operations):
    # import file to get cell names
    gdsii = gdspy.GdsImport(file_name)
    # append all cell names with the 'i' counter
    names = {c: '{}_{}'.format(c, i) for c in gdsii.cell_dict}
    # just out of curiosity:
    print('\nRenaming cells in ' + file_name + ':')
    print(names)

    # import again renaming all cells and extract the result
    gdsii = gdspy.GdsImport(file_name, rename=names)
    cell = gdsii.extract(gdsii.top_level()[0])

    # apply the respective operation
    ref_cell.add(gdspy.CellReference(cell, **operations[file_name]))

gdspy.gds_print('new_gds.gds', cells=[ref_cell], unit=1.0e-6, precision=1.0e-9)

from gdspy.

Engi4 avatar Engi4 commented on July 19, 2024

Thank you so much! You are a scholar and gentleman!
I learned so much from your replies and from your library in general. Thank you very much. I will try to familiarize myself more with the documentation of the library.

from gdspy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.