Transformation for PCell in Ruby

edited April 2015 in General
Hi, I have a PCell coded in Ruby similar to the example on the documentation. Pieces are inserted to the layout in the produce_impl method. I would like to be able to mirror everything after it gets drawn/inserted (i.e. transform the entire structure). How can I do this with my Ruby file?

Thanks,
-D

Comments

  • edited November -1

    Hi diegonolovich,

    The following code works for normal cells, but I think it should also work for a PCell. Just add the following code to the end of your produce_impl method:

    t = Trans.new(Trans::M90)
    cell.each_inst do |inst|
      inst.transform(t)
    end
    
    layout.layer_indices().each do |layer_index|
      cell.each_shape(layer_index) do |shape|
        shape.transform(t)
      end
    end
    
  • edited April 2015

    Diego,

    friendfx's solution looks fine

    Two other solutions just for purpose of edification:

    Depending on how many shapes (or cells) you are inserting within produce_impl, you could also transform as you insert them. So any line that looks like this:

    cell.shapes(out_layer).insert(polygon)
    

    you could change to this:

    cell.shapes(out_layer).insert(polygon.transformed(trans))
    

    where trans = Trans.new(Trans::M90) is the transformation.

    Another alternative: Instead of transforming the shapes inside the PCell, it may be preferable to transform the entire PCell when it's placed. If you are placing the PCell via script (example) rather than by hand, then you can put something like:

    pcell_inst = layout.cell(top).insert(CellInstArray::new(pcell_var, trans))
    

    Note that that code is not in the PCell code, it exists in code that calls the PCell code (to be able to place a PCell instance). This allows you to later select the PCell with your mouse, press 'q', and you will see the transformation under "Rotation" and "Mirror" options, and can edit that later.

    David

  • edited November -1
    Thanks! This did the job nicely.

    -D
Sign In or Register to comment.