Hi
i am trying to combine these 2 topics.
Is it possible to place many instances of a cell to a text list of x,y coordinates?
http://klayout.de/forum/comments.php?DiscussionID=370
and
Array selected objects
http://klayout.de/forum/comments.php?DiscussionID=321&page=1#Item_0
The codes I found here is
A.
# create a new view (mode 1) with an empty layout
main_window = RBA::Application::instance.main_window
layout = main_window.create_layout(1).layout
layout_view = main_window.current_view
# set the database unit (shown as an example, the default is 0.001)
layout.dbu = 0.001
# add a cell (in this case "TOP")
cell_index = layout.add_cell("TOP")
cell = layout.cell(cell_index)
# create a layer (in this sample layer 10, datatype 0)
layer_index = layout.insert_layer(RBA::LayerInfo::new(10, 0))
# add shapes now
# TODO: read the text file and create one shape on each location read
# (in this sample a single box with lower left corner being a 0,0 and
# width of 1um and height of 2um is created)
cell.shapes(layer_index).insert(RBA::Box::new(0, 0, 1000, 2000))
# select the top cell in the view, set up the view's layer list and
# fit the viewport to the extensions of our layout
layout_view.select_cell(cell_index, 0)
layout_view.add_missing_layers
layout_view.zoom_fit
B.
ly = ... # the layout
unitcell_index = ... # cell index of the unitcell
arraycell_index = ly.add_cell("ARRAY")
arraycell = ly.cell(arraycell_index)
nx = ... # number of columns
dx = ... # column pitch
ny = ... # number of rows
dy = ... # row pitch
arraycell.insert(RBA::CellInstArray::new(unitcell_index, RBA::Trans::new,
RBA::Point::new(dx, 0), RBA::Point::new(0, dy), nx, ny)
I am having trouble to combine these 2 codes and hoping to find some solution here.
The goal is to create shape then make array of it, then create another shape then array that one again...so on.
thanks
Comments
Hello,
Could you please be more specific? What's your input and what is the expected output?
Both pieces of code refer to a specific problem, and I don't think they easily combine to solve yours.
If you need more information about writing scripts and the database API in general, please try http://www.klayout.de/doc/programming/index.html. You should also be familiar with Ruby. There are numerous tutorials out there, so it should be easy to find one that suits you.
Thanks,
Matthias
Thanks for the reply.
My goal is to use script to draw a 1um by 1um box then make it a array of 100 row and column with pitch of 2um, then continue to draw a 3um by 2um box then make it a array of 50 row and column with pitch of 5um
That's why I started to search from forum to see if there is any code I can combine to make it happen.
Code A from above, can help me to draw 1um by 1um box and 3um by 2um box, but somehow I can't use Code B from above, to "make array" the 2 boxes that I created previously with different pitch and numbers of column/rows.
thanks.
Hi,
the code above illustrates how to create a shape and how to instantiate a cell so it becomes a cell array. This is one way to create an array. The two codes above combine like this:
You'll need to add the code to repeat the steps from creating the unit cell to creating the array instance. Don't forget to adjust the origin on each step.
Another way to create an array is by iterating the coordinates inside your script and producing 100x100 rectangles directly, This will produce somewhat bigger files and is somewhat slower but is also a valid approach.
Matthias