Does klayout has a function somewhat like snap to point?


I want to ask could klayout has a function somewhat like "snap to point", which can quickly move layout?
Could anyone know?

Thank you in advance!


  • Could you explain in more detail what you're looking for?


  • Hi,

    1) snap to grid: you can set your snapping grid via menu:

    Edit > Editor Options > Snapping > Grid "Global grid" (or "Other grid")

    I normally define a wide range of default grids (global grid) in the setup, something like:


    and select the one I need via menu View > Grid.

    2) move to point: you can move selected structures via menu:

    Edit > Selection > Move To (or Move By)



  • If you want to touch only one point, I believe Partial
    (stretch) will move a vertex to the next grid-snap by
    hand. Not sure about multiple-selected vertices, you
    would have to play to see whether it does what you

    A "snap all vertices to grid" could be cool, but also
    risky (you might, say, change your 90 / 45 /45 degree
    polygon to 90 / 44.8 / 45.2 or something like that if
    the "where's my best snap?" algorithm gets tricked?).

  • Because of such behaviors I often find it better to
    "over-stretch" the polygon, and use an on-grid
    "cutter" shape with "Subtract, others from first"
    to shave off any off-grid "material".

  • @Matthias,

    Sorry for the late reply.
    I mean, the layout region full with vertices whose spacing is 0.001um.
    And we can drag the polygon/shape to the specified vertice.
    Could this be achieved more quickly?

    Currently, I can move the shape to speified point by "move by" function or drag several times to get to specified point finally.

    Is there some way more quickly to drag the shape to specified vertice which I see by eye?

  • @tomas2004 ,

    Thank you very much for your respond. I always choose the second way you mentioned.

    But I don't understand the first way you mentioned.
    You mean, I can set the snap like this?

    But, it seems that there is slight improvement for speed.

    Best regards!

  • @dick_freebird ,
    Thank you very much for your respond.
    My original goal is not to find vertice which isn't on grid.
    Your reminder is very helpful. It is true that the shapes formed from angles may not be displayed on the grid, but it cannot be placed on the grid at will.

    The botton " Subtract, others from first"you provide will be very helpful to shave off any off-grid "material" in some cases.
    I wonder, does this "snap all vertices to grid" and "over-stretch" are function in klayout or just explanatory nouns which not exist in klayout?

  • Those were my attempt to explain how I do things.

    If they were klayout functions, they might be useful but
    I also anticipated some risky behaviors (such as a 45
    turning into a not-exactly-45 due to rounding errors or
    something like that). Or circles becoming "toothed
    gear" vertex by vertex as snapping pulls them inward
    or outward depending on each vertex's round-off.

  • Hi Weiling,

    The snapping grid is used when drawing new shapes or moving existing shapes. Normally it is the global grid, but you can quickly override it by defining an "Other grid...". Putting the "Other grid..." to 0.001 does not make much sense if your DBU is also 0.001 because all structure snap to DBU by default even if snap to grid is disabled.

    If your layout contains a lot of 0.001 gaps (spacing) the only way to correct it fast is by layer operations:

    1) size all shapes with 0.001/side
    2) merge all shapes
    3) size all shapes with -0.001/side

    Note that the new layers will be fully flattened...



  • @dick_freebird,
    Thank you for your detailed respond.
    Your worries are possible and justified.
    I got it.
    Thank you again.

  • @tomas2004 ,

    Thank you for your respond.

    For a layout with many gaps of 0.001um, I followed your method, but It didn't make function, does it only take effect when the space is smaller than 0.001um for shapes formed by angle?

    The original shape:

    1) size all shapes with 0.001/side
    The generated shape is shown in Layer 2/0:

    2) merge all shapes
    The merged shape is shown in Layer3/0:

    3)size all shapes with -0.001/side
    The sized shape is shown in Layer 4/0:

    It seems that it doen't take effect for space of 0.001um.
    So maybe it’s my understanding or operation wrong?

    Best regards!

  • If space is exactly 0.001, and snap is 0.001, does
    that leave it "nothing to do"?

  • @dick_freebird ,

    I can't find a better way other than moving it manually.

    Could anyone give some better method?


  • Hi Weiling,

    You should "refuse" such kind of designs, they cause a lot of troubles...
    Once you merged the polygons, maybe you could iterate over the points of the new polygons by script: look at ΔX and ΔY of two adjacent points and when it is smaller than a specific value (0.001 in your case), but larger than 0, set the X and/or Y coordinate(s) of the second point equal to the X and/or Y coordinate(s) of the first point...



Sign In or Register to comment.