inserting shape with defining layer property

edited December 2019 in Ruby Scripting

Hi
I have beginner's question. The goal is to draw shape in the specific layer (1,0) and then define layer (1,0) with better olor/stipple setting. However, one layer (1,0) is generated by "layout_view.insert_layer", then when I try to insert a shape, another (1,0) also shown up.....now I have 2 (1,0) layers with exactly the same shape in it.

thanks

#=============


include RBA

main_window = RBA::Application::instance.main_window

layout = main_window.create_layout(1).layout

layout_view = main_window.current_view

layout.dbu = 0.001

cell_index = layout.add_cell("TOP")

cell = layout.cell(cell_index)

unit_cell_index = layout.add_cell("Cell1")

unit_cell = layout.cell(unit_cell_index)


a  = [RBA::Point::new(0,0),\

RBA::Point::new(100,0),\

RBA::Point::new(100,100),\

RBA::Point::new(300,300),\

RBA::Point::new(0,300),\

RBA::Point::new(50,150),\

]



ln = RBA::LayerPropertiesNode::new

ln.dither_pattern = 15

ln.fill_color = 0xffff00

ln.frame_color =0xffff0f

ln.width =1

#ln.source_layer_index = layer_index2

  ln.source_layer = 1

  ln.source_datatype = 0



layout_view.insert_layer(layout_view.end_layers, ln)

cell.shapes(layout.layer(1, 0)).insert(RBA::SimplePolygon::new(a ))

layout_view.select_cell(cell_index, 0)
layout_view.add_missing_layers

layout_view.max_hier

layout_view.zoom_fit

Comments

  • Hi,

    thanks for this nicely prepared test case.

    The problem is definitely not a beginner's question. The reason why the layer is not skipped in "add_missing_layers" is that you need to add the cellview index (the index of the layout loaded into one tab) to the source specification for it to become complete.

    Here is my modified code (I took the liberty of some reformatting and removed the "include RBA" which is not required and will only pollute the system's global namespace:

    main_window = RBA::Application::instance.main_window
    
    # NOTE: we need to keep the CellView index (somewhat cleaner -
    # right now, this is always 0 because we create a fresh view)
    cellview = main_window.create_layout(1)
    cellview_index = cellview.index
    layout = cellview.layout
    
    layout_view = main_window.current_view
    
    layout.dbu = 0.001
    
    cell_index = layout.add_cell("TOP")
    cell = layout.cell(cell_index)
    unit_cell_index = layout.add_cell("Cell1")
    unit_cell = layout.cell(unit_cell_index)
    
    a = []
    a << RBA::Point::new(0,0)
    a << RBA::Point::new(100,0)
    a << RBA::Point::new(100,100)
    a << RBA::Point::new(300,300)
    a << RBA::Point::new(0,300)
    a << RBA::Point::new(50,150)
    
    ln = RBA::LayerPropertiesNode::new
    ln.dither_pattern = 15
    ln.fill_color = 0xffff00
    ln.frame_color =0xffff0f
    ln.width =1
    ln.source_layer = 1
    ln.source_datatype = 0
    # NOTE: for a complete specification we also need to add the cellview index
    ln.source_cellview = cellview_index
    
    layout_view.insert_layer(layout_view.end_layers, ln)
    
    cell.shapes(layout.layer(1, 0)).insert(RBA::SimplePolygon::new(a ))
    
    layout_view.select_cell(cell_index, 0)
    layout_view.add_missing_layers
    layout_view.max_hier
    layout_view.zoom_fit
    

    Kind regards,

    Matthias

Sign In or Register to comment.