Generate images from a list of sites and FOV size

Hey folks,

I have a list of coordinates (x,y). I would like to do something like this

Goto position 1
Zoom to FOV (lets say 15um by 15um)
Save screen capture
Goto position 2

I've looked at a few posts (such as that do something similar but I haven't found anything that's exactly what I am looking for. If anyone knows of an existing macro for doing this that would be great.



  • edited July 2020

    Hi Scott,

    well, it would be a lot of luck to find exactly your script out there :)

    Here is a working Python script example which basically does what you need. The list is taken from an array, but with a little bit of Python skill it should be easy to code a reader for a text file to read these values from:

    import os
    # A list of coordinates (x, y) in micrometers, the window size (micrometers)
    # and the name of the file to produce
    coords = [
      [ -392, -600,  100, "img1.png" ],
      [   40,  300,  100, "img2.png" ]
      # more ...
    # Image resolution
    width  = 400
    height = 400
    # Output directory (please change)
    out = "/home/matthias/screenshots"
    lv = pya.LayoutView.current()
    for cspec in coords:
      (x, y, dim, fn) = cspec
      center = pya.DPoint(x, y)
      dv = pya.DVector(dim * 0.5, dim * 0.5)
      lv.zoom_box(pya.DBox(center, center).enlarged(dv))
      fn_path = os.path.join(out, fn)
      print("Saving image for position " + str(center) + " to " + fn_path)
      lv.save_image(fn_path, width, height)


  • Thank you sir! This should be enough to get me on my way. Really appreciate the response as well as the entire Klayout software package.

  • edited September 2020

    deleted to post separate discussion on Python Scripting subforum

Sign In or Register to comment.