"copy_shapes" method

Hi Matthias,

I was looking into some simple code to copy the cell which is being viewed:

layout_view = Application.instance.main_window.current_view
layout = layout_view.active_cellview.layout
viewed_cell = layout_view.active_cellview.cell

viewed_cell_copy = layout.create_cell(viewed_cell.name + "_duplicate")

viewed_cell_copy.copy_instances(viewed_cell)

viewed_cell_copy.copy_shapes(viewed_cell)

This works fine but if I add a transcation for undo/redo it fails on the "copy_shapes" method (but not on the "copy_instances" method). Is that intentional?

    layout_view = Application.instance.main_window.current_view
    layout = layout_view.active_cellview.layout
    viewed_cell = layout_view.active_cellview.cell


 begin

  layout_view.transaction("duplicate viewed cell")

  if layout_view == nil

    raise "Shape Statistics: No view selected"

  end #  if


    viewed_cell_copy= layout.create_cell(viewed_cell.name + "_duplicate")

    viewed_cell_copy.copy_instances(viewed_cell)

    viewed_cell_copy.copy_shapes(viewed_cell)


ensure

  layout_view.commit

end #  begin    

Cheers,

Tomas

Comments

  • Hi Matthias,

    I was trying the code at the top of the post above, and I noticed that, if the viewed cell:

    1) contains instances and shapes > _duplicate cell is ok, contains both instances and shapes
    2) contains only instances > _duplicate cell is ok, contains the instances
    3) contains only shapes> _duplicate cell is not ok, it is empty???

    Same if using the "dup" method... Can you reproduce?

    Cheers,

    Tomas

  • No, of course that isn't!

    That's a bug. I created a ticket for this: https://github.com/KLayout/klayout/issues/864

    As a workaround you can do it layer per layer:

        layout.layer_indexes.each do |li|
            viewed_cell_copy.shapes(li).insert(viewed_cell.shapes(li))
        end
    

    Matthias

  • Hi tomas2004/Matthias
    If I want to copy a cell instance from gds file into current library, and that gds file location in NAS
    such as //Nas/path/1.gds
    that cellname is "frame"

    in my idea , our designer always need to ....
    1.open a new library.
    2.copy mother frame cell from NAS.
    that file is what our basic cell.
    after step 2 , our designer start some of design working.
    so , could you please let me know how can I do that in scribe?

Sign In or Register to comment.