It looks like you're new here. If you want to get involved, click one of these buttons!
Hi,
Here is my code for flatten the "cell". (where "cell" is the cell I want to flatten)
my problem is:
1. why I can't flatten only 1 level with setting the "1" argument
2. I feel strange that the flatten function is not directly flatten the "cell", but I need to first search the parent cell, then use parent_cell.flatten(1) to flatten the "cell"
3. #1, #2 bring me to the other problem, if the parent cell is not only contain "cell", but also others, then the other cells also be flatten.
4. I would like to know that if "cell" call as an array, will cell.flatten also work?
So, how can I flatten the "cell" directly with affect the any other cells? Thanks.
seatch_for_cell = layout.cell(want_to_flatten)
for p in seatch_for_cell.each_parent_cell():
c = layout.cell(p)
c.flatten(1)
BG,
Man
Comments
@Man
1.) please read the documentation. Flatten with one argument takes a single "bool" which is the "prune" parameter. "flatten" with a level is "flatten(level, prune)".
2.) you impose a specific interpretation of "flatten". "Cell#flatten" will make the cell "flat" (so it does not have a hierarchy). It does not flatten away the cell (resolve it). The latter is an operation on a cell instance, because this instance is going to replaced by the content of the cell. The respective method is "Instance#flatten". This will also solve 3.).
4.) I think arrays should work as well.
A very simple way to do a "flatten away" is to use this one-line custom query in "search and replace":
(replace CELL_TO_FLATTEN with the name of your cell)
Matthias