Rotation of Shapes

edited October 2016 in General
Hallo,
I would like to extract bitmaps at a fixed rectangular window of given gdsii-file.
Afterward I rotate the all shapes in the file and extract again an so on ...
All shapes are on the same layer - Cell: structure.
How can rotate the shapes at certain angle (without add a new cell)?
I've read ICplxTrans should do that but I can't get it working.
Thank you!
Ulli

---

# input file
input_file = $file

# width, height of image
width = 160
height = 2400

# rectangle to draw (left, bottom, right, top in micron coordinates)
rect_drawn = RBA::DBox::new(-80.0, 24800.0, 80.0, 27200.0)

# output file
output_file = $output

# load the layout
mw = RBA::Application::instance.main_window
ly = mw.load_layout(input_file, 0)
view = mw.current_view
view || raise("No view open")

# load layer properties
prop_file=$prop
RBA::LayoutView::current.load_layer_props(prop_file)

# rotation ???
#t = RBA::ICplxTrans::new(1.5, 90.0, false, 10.0, 20.0)

# select full hierarchy and the rectangle to draw
view.max_hier
view.zoom_box(rect_drawn)

# save image
view.save_image("#{output_file}", width, height)

---

Comments

  • edited October 2016

    Hi Ulli,

    if it's just about drawing the layout in a different orientation you don't need to modify the layout.

    Instead you can modify the view's global transformation like this:

    RBA::LayoutView::current.set_config("global-trans", RBA::DCplxTrans::new(1.0, 90, true, RBA::DPoint::new).to_s)
    

    this example will impose a 90 degree rotation on the view. Please note that contrary to the expectation setting a magnification in the transformation does not have an effect since the physical area shown will be maintained and the zoom factor will be adjusted accordingly, compensating the effect of the magnification. Chose a smaller zoom box instead.

    You can also prepare a layer properties file that includes transformed views. To do so, group all layers so a new layer node will be created atop of the layers. Then chose "Select source" on this one from the layer list's context menu and enter a transformation (i.e. "(r90)"). Saving the layer properties to a new .lyp file will allow you to impose a transformation just by loading this file. You'll find more details about layer source specifications here: http://www.klayout.de/doc/about/layer_sources.html.

    Regards,

    Matthias

  • edited November -1
    Hi Matthias,

    this rotation of Layout views won't help, because I have to rotate the whole layout that correspond to the origin (0,0) - I was completely off track to try it with rotation of selected views, sorry. This could maybe help in later tolerancing investigations.
    But this layout is actually a calculated section of a disk. I would like to cut a certain rectangular bitmap windows at different angles from this section. Therefor the easiest way would be to rotate the section of disk completetly and extract the rectangular view afterwards at a fixed window. I tried this in the editor:<Edit><Layout><Rotate By Angle>. This worked fine but to do it manually for many angles is not very convenient. Therefore a script is needed.

    Thank you!

    Ulli
  • edited November -1

    To rotate the whole layout for example by 22.5 degree around the origin (0, 0) use

    layout.transform(RBA::ICplxTrans::new(1.0, 22.5, false, 0, 0))
    

    Matthias

  • edited November -1
    Hi Matthias,

    this is what I'd looked for. Now it works like a charm.

    Thank you very much!

    Ulli

    my final result:
    ---

    # input file
    input_file = $file

    # width, height of image
    width = 160
    height = 2400

    # resolution of rotation
    resolution = 0.001

    # counts of rotation
    rotcount = 10

    # rectangle to draw (left, bottom, right, top in micron coordinates)
    rect_drawn = RBA::DBox::new(-80.0, 24800.0, 80.0, 27200.0)

    # output file
    output_file = $output

    # load the layout
    mw = RBA::Application::instance.main_window
    mw.load_layout(input_file, 0)
    layout = RBA::CellView::active.layout
    view = mw.current_view
    view || raise("No view open")

    for i in 0..rotcount

    count = resolution * i

    # load layer properties
    prop_file=$prop
    RBA::LayoutView::current.load_layer_props(prop_file)

    # select full hierarchy and the rectangle to draw
    view.max_hier
    view.zoom_box(rect_drawn)

    # save image
    view.save_image("#{output_file + count.to_s + ".png"}", width, height)

    # rotation layout
    layout.transform(RBA::ICplxTrans::new(1.0, resolution, false, 0, 0))

    end

    ---
Sign In or Register to comment.