Skip to content

Multi-cell copy_tree with common subcells only copied once #639

Closed
@klayoutmatthias

Description

@klayoutmatthias

This is a problem that pops up now and then. Recent case: https://www.klayout.de/forum/discussion/1628/how-to-import-the-cell-which-shares-the-same-subcell-with-other-cell-over-python-scripting

The problem is: when copying over a cell from one layout to another, the full tree is copied always. If multiple cells are copied, common subcells are not shared, not duplicated.

A solution is required to provide multi-cell copies while sharing common subcells. The "multi_clip_into" feature for example provides this ability already.

Solution:

The solution consists of two methods: Cellmapping#for_multi_cells_full will create the target structure and prepare a mapping table and Layout#copy_tree_shapes will copy the shapes.

Here is some sample code:

l = ... # source layout
lt = ... # target layout

target_cells = ... # array of cell indexes to which cells to copy (in target layout)
source_cell = ... # array of cell indexes from which cells to copy (in source layout)

# NOTE: target_cells.size must be equal to source_cells.size

# Prepare a cell mapping (this will also create the necessary subcells in the target layout)
cm = RBA::CellMapping::new
cm.for_multi_cells_full(lt, target_cells, l, source_cells)

# Copy the cell's shapes
lt.copy_tree_shapes(l, cm)

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions