Problem with anysotropic scaling script (edited)

edited December 2015 in Layout
Hello,

I use Klayout to do transformation of designs to adapt with a direct laser writer.

I would like to scale my design with different values horizontally and vertically. The scale function only has one parameter. Is there a way to do this anyway?

Any help would be greatly appreciated! :)

Theo

Comments

  • edited December 2015
    I have found this script
    http://178.77.72.242/svn-public/klayout-resources/trunk/scripts/scale_anisotropic.lym
    I tried to execute it, but I get an error:
    undefined local variable or method `gt' for AnisotropicScaling:Module
    /Users/theophane/.klayout/macros/AnysotropicScaling.lym:40:in `<module:AnisotropicScaling>'
    /Users/theophane/.klayout/macros/AnysotropicScaling.lym:13:in `<main>'

    [edit] I copied from Firefox instead of importing the script with the "macro development" tool
  • edited December 2015

    With regards to your original question: I assume you want to anisotropically scale the whole layout (all shapes on all layers in all cells) by some fraction, like 1.1,1.2 (10%,20%). Is that correct? In that case you could write a script but it's not trivial so I wanted to understand the question before starting to offer the wrong answer.. (I don't currently have such a script, it would be some work to write.) So you are looking for Edit > Layout > Scale, but with two parameters.

    With regards to your second question:

    • First, the solution: .lym files are XML. In XML, " & g t ; " (ignore the spaces, I need to do that to trick KLayout.de's forum to correctly represent it) represents the ">" character. I can't quite tell but I think what you seem to have done is to copy the text from your internet browser in to a new macro. Instead, either save the entire .lym file as a new file straight from your browser (no copy-paste), or else copy and paste it in to a new document using a text editor of your choice, save as .lym, then move that file to "macros" folder and restart KLayout to find it. Now you will find that the " & g t ; " has been changed to ">" (and other changes too probably) as KLayout Macro IDE has correctly interpreted the XML file.
    • Next, a comment: Even if you do the above, it may not be what you want. That script simply scales any polygons and boxes. It may not scale the whole layout like you want it to. Basically I think it's the same as the built-in Edit > Selection > Size shapes. There is also a similar function in Edit > Layer > Sizing. These two functions both allow two parameters for anisotropic scaling (in other words you don't even need that .lym file -- I believe it's an old file from the days before that anisotropic scaling function was natively built in to KLayout), but work on shapes or on whole layers respectively. The latter scales each shape on each layer in place rather than scaling the whole layer proportionally, which is not what you want, I think.

    David

  • edited November -1
    Hi David,

    Thank you for your answer.

    I indeed copied the text instead of importing it. Noticed my mistake after 20 minutes :)
    What I want to do is scaling my whole design with different values for x and y. This is the equivalent to Edit>selection>scale but with two values.

    This script works really well, it scales my whole design. You have to flatten the design first (which can be slow or impossible, but that is to be expected as it seems too complicated to do an anisotropic scaling on instances.
    The situation is: I measure alignment crosses with a laser exposer and I want to align the layer with scaling in order to improve the alignment accuracy.

    The layer sizing you propose is more like a "growing" function as I understand it. It increases the size of the different shapes by x and y um (additive) without moving the shapes. I don't really want that, I want to increase the size of the design by factors of x and y. But thanks for the tip, this function can be really useful to adapt the critical dimension when there is overexposure!

    Théo
  • edited December 2015

    Hi Theo,

    hierarchical, anisotropic scaling is possible, but that involves generation of variants for differently oriented cells. Right now, flattening is the only feasible option.

    Flattening is considerably faster if you don't chose undo support. Flattening by script is also possible and maybe more efficient. In general, the scaling script will do the scaling within Ruby which is probably very slow too. I efficient solution on big data sets can only be done within C++.

    Apart from scaling - this is just a very simple correction. Will you finally need other (affine) corrections as well? Like rotation, shear and trapezoid? There actually is a transformation class for that (Matrix3d), but then flattening is mandatory.

    Matthias

  • edited December 2015
    Hi Matthias,

    I understand it is complicated, It would be nice not to have to flatten, but right now, I can work with it.

    Flattening is quiet fast (I used to work with clewin and it is lightening fast in comparison), but past a certain number of polygons, it seems to run indefinitely. Is it possible to flatten with the built in functions and disable the undo function, or do I have to develop a ruby script?

    edit: found it. When flattening a cell, the software ask to disable the undo function but when using edit>selection>flatten_instances, it does not ask. But the program still freezes if there are too many structures to flatten

    This is a really interesting point, I actually use scaling combined with other transformations to simulate shear and trapezoid, so this would be a very nice addition! Would it be possible to have a generic transformation where we can specify a matrix of transformation?

    Thank you for your help

    Théo
  • edited November -1

    Hi Theo,

    you can disable globally by calling KLayout with the "-i" option for that purpose.

    Flattening is a memory-consuming operation often. Small layouts may explode to an infinite number of shapes if you're unlucky. Freezing may be an effect of swapping. Can you check whether the process runs out of physical memory?

    Matthias

  • edited November -1
    Hi Matthias,

    I have a design with an array of ~1500 cells. The flattening of one cell seems instantaneous. If I try to flatten the whole design containing this array of 1500 cells, the memory doesn't increases so much that it starts to swap, but klayout starts to use 100% of the thread. I let it run for two hours before killing the program. (same behavior with Linux and OS X).
    If I flatten only one third of the cells, it works and ends after less than 3 minutes.
    If a reduce the number of polygons in the cell composing the array, it works.

    I cannot really investigate farther.

    Théo
  • edited November -1

    Hi Theo,

    Looks like a there is a performance trap here.

    I think I can provide a solution in 0.24.4.

    Best regards,

    Matthias

  • edited November -1
    Hi Matthias,

    It indeed seems to work now when the undo function is bypassed, thanks!

    Théo
Sign In or Register to comment.