Moving a GDS

edited October 2013 in Ruby Scripting
Hi,

I would like to write a Ruby script code that received GDS and 2 or 4 coordinates, and move the GDS according to the new coordinates that had received.
Is there any script for it?
May I use the "box::Move" method? (I did not find any example for that method so I don`t know how to use this option...)
And how many coordinates should I got- 2- for (x, y) - the lower left corner , or maybe 4 coordinates- also for the up right corner?

thanks a lot

Lital

Comments

  • edited October 2013

    Hi Lital,

    There are two ways to move a layout:

    First you can build a new cell atop of your current top cell and instantiate your original top cell giving the instance a shift vector. That simple solution effectively moves you whole layout but introduces a new level of hierarchy.

    If you can't afford that, there is another solution which requires you to transform shape by shape and instance by instance in your top cell (only there). That is slower but does not introduce new cells:

    layout = ... # your RBA::Layout object
    top_cell = ... # the RBA::Cell of your top cell
    
    # the transformation to apply
    t = RBA::Trans::new(dx, dy)
    
    # transform the shapes
    layout.layer_indices.each do |li|
      top_cell.shapes(li).each do |s|
        s.transform(t)
      end
    end
    
    # transform the instances
    top_cell.each_inst do |i|
      i.transform(t)
    end
    

    BTW: this will be much simpler in 0.23 ...

    Matthias

  • edited November -1
    Hi again

    First, thanks for helping, it really helped me

    I am trying to run the script but I don't see any results

    That is my code:

    1) gds = $input.split.collect
    2) tmp_cell = $top.split.collect

    3) c = $coordinates.split(",").collect { |c| c.to_i }
    4) c.size == 2 || raise ("Coordinate list must have two entries")

    5) gds = gds.to_s
    6) layout = RBA::Layout.new
    7) layout.read(gds)

    8) tmp_cell = tmp_cell.to_s
    9) top_cell = layout.cell(layout.add_cell(tmp_cell))

    10) point1 = RBA::Point::new(*c)

    11) # the transformation to apply
    12) t = RBA::Trans::new(point1)

    13) # transform the shapes
    14) layout.layer_indices.each do |li|
    15) top_cell.shapes(li).each do |s|
    16) s.transform(t)
    17) end
    18) end

    19) # transform the instances
    20) top_cell.each_inst do |i|
    21) i.transform(t)
    22) end


    I think that my problem is with the way that I am trying to save the top_cell (lines 8,9), that is the way I know, it is right?
    or maybe I have other problem?
    (I should see the result in the same GDS, after reload, right?)

    thanks again
    Lital
  • edited November -1

    Hi Lital,

    I guess it will work if you use "cell_by_name" instead of "add_cell" in 9.).

    "add_cell" will create a new cell which then is empty so there is nothing to transform. Use "cell_by_name" will return an existing cell with the given name.

    For safety you should check whether there actually is a cell with that name with "has_cell" and raise an error if that gives false.

    Regards,

    Matthias

Sign In or Register to comment.