Python region Merge does not behave like Ruby region Merge

So adding to my tool box of code
The following Ruby code works as expected
The similar Python code does not.
It just copy's the same shape over the other
no merge.
I am either missing something or dumb or just plain .....

Code as follows

#############################################################
Ruby

include RBA
lv = Application.instance.main_window.current_view
ly = lv.active_cellview.layout
dbu = ly.dbu
cell = lv.active_cellview.cell

# Enter your Ruby code here
layer_info = LayerInfo.new(9,0)
layer_index = ly.layer(layer_info)
layer = layer_index  # the layer index from which you want to take the polygons

# creates a region containing all polygons from the cell's layer plus all the
# polygons from it's children.
region = RBA::Region::new(cell.begin_shapes_rec(layer))

# merges the polygons (in-place: the region is filled with the merged polygons)
region.merge

# clears the input layer (in all cells) and puts the 
# merged polygons back into the cell
cell.layout.clear_layer(layer)
cell.shapes(layer).insert(region)
#############################################################

Python

import pya
import sys
layout = pya.Layout()
#layout = pya.Application.instance().main_window().current_view().active_cellview().layout() 

if layout == None:
  raise Exception("No layout")

cv = pya.Application.instance().main_window().current_view().active_cellview()
dbu =layout.dbu

cell = pya.Application.instance().main_window().current_view().active_cellview().cell
if cell == None:
  raise Exception("No cell")

layer_info = LayerInfo.new(9,0)
layer = layout.layer(layer_info) # the layer index from which you want to take the polygons

# creates a region containing all polygons from the cell's layer plus all the
# polygons from it's children.
region =pya.Region.new(cell.begin_shapes_rec(layer))

# merges the polygons (in-place: the region is filled with the merged polygons)
region.merge

# clears the input layer (in all cells) and puts the 
# merged polygons back into the cell
layout.clear_layer(layer)
cell.shapes(layer).insert(region)
#############################################################

Comments

  • I have had exactly the same issue! No luck so far!

  • edited March 2021

    See my reply to the last discussion along this line.

    region.merge()
    

    With BRACKETS, for heavens sake! This is Python. One reason why I hate it.

    Matthias

  • hmm.... one to one conversions never show in the documentation that you need bracket's just saying.
    that said . thank's will add the brackets.

  • calm down, I have been doing this for the better part's of 35 so year's,
    your tool is great , but I find that there are little nascence's here there and about everywhere
    that only you know of , that said give us some slack

Sign In or Register to comment.