Shape Rotation by script

edited April 2014 in Ruby Scripting
Dear all,

I would like to rotate a shape by script.
For example,

I use this following script can create a shape:

startx = ring_centerx - rbendring # The x coordination of grating waveguide
starty = ring_centery # The y coordination of grating waveguide
wg_left = RBA::Box::new_lbrt( startx - w_o * 0.5, starty , startx - w_o * 0.5 - etchw, starty + wglen2)
topcell.shapes( layer_id2 ).insert_box( wg_left )
wg_right = RBA::Box::new_lbrt( startx + w_o * 0.5, starty , startx + w_o * 0.5 + etchw, starty + wglen2)
topcell.shapes( layer_id2 ).insert_box( wg_right )

How can I rotate the shape by 15 degree by ruby script?

Thank you very much.

Aaron

Comments

  • edited November -1

    Hi Aaron,

    you'd like to rotate the box before you insert it?

    Well, the solution is to use a polygon (a box won't rotate by an arbitrary angle) and to use a transformation:

    # Rotation by 15 degree, no mag, no mirror, no displacement
    rot15 = RBA::ICplxTrans::new(1, 15, false, RBA::Point::new)
    
    wg_left = RBA::Box::new_lbrt( startx - w_o * 0.5, starty , startx - w_o * 0.5 - etchw, starty + wglen2)
    topcell.shapes( layer_id2 ).insert(RBA::Polygon::new(wg_left).transformed(rot15))
    

    Matthias

  • edited November -1
    Dear Matthias

    This is exactly what I want. But I still have another question.
    The rotation corresponds to the origin (0,0), right?
    How can I move the shape before I insert it?

    Thank you very much~

    Aaron
  • edited November -1

    Hi Aaron,

    the displacement is the forth parameter of the ICplxTrans constructor. The other parameters are: magnification, rotation angle, mirror flag.

    The operations are applied in that order: magnification, mirror (at x axis), rotation and finally displacement.

    Matthias

  • edited November -1
    Thank you very much~
Sign In or Register to comment.