Create a shape in an active cell

Hello. Klayout newbie here. I have a silly question.
So I tried to create a shape in my existing layout. Below is the script.

include RBA
app = RBA::Application.instance
mw = app.main_window
lv = mw.current_view
cv = lv.active_cellview
# define points in the shape here
circle = Polygon.new(pts)
cv.shapes(circle_layer).insert(circle)_

Then there is an error saying shapes is not a method for cellview. I guess defining cv as lv.active_view doesn't make cv a cell object. How can I point to the current cell and create a shape then?
I browsed many examples. Most of them start by creating a cell, which doesn't apply here.
Thanks!

Comments

  • Hello kikixu90,
    devired from another contribution in this forum, here is an example. The code is not functional, but I think it solves your problem.

    Best Leo

    module MyMacro
    
    # Inserts a circle segment poly resistor given by its thickness and squares and
     # adds other cells for 
    include RBA
    layout_view = Application.instance.main_window.current_view
    
    ##### I think you missed these lines
    cur_layout = layout_view.active_cellview.layout
    #output cell
    out_cell = layout_view.active_cellview.cell
    ####
    
    #use layer 14 for drawing
    polyLayer=cur_layout.layer(14,0)
    
    ###....
    
    ####create shape (path in this case)
    polyR=[]
    
    for i in 0..npts
      polyR.push(Point.from_dpoint(DPoint.new(x_point,y_point))
    end
    #### end of shape creation
    
    ###insert into out_cell which is defined above
    out_cell.shapes(polyLayer).insert(RBA::Path::new(polyR,thickness/dbu))
    
    end
    
  • Yes, the solution basically is to use "cv.cell" rather than "cv" itself.

    "CellView" is identifying a particular layout shown in a "LayoutView" in terms of layout, cell shown etc. Use the "cell" property to access the cell which is currently shown. With this cell object you can use "shapes" to access the shapes container for a single layer.

    Matthias

Sign In or Register to comment.