It looks like you're new here. If you want to get involved, click one of these buttons!
Back to bother you again.
I’ve been assigned a task to make a GDS file of a Mandelbrot Fractal. I’ve found a short VB Excel macro code below.
For y = 1 To 200
For x = 1 To 200
i = 0
zx = 0
zy = 0
cx = -2 + x / 50
cy = -2 + y / 50
Do Until (i = 255) Or (zx * zx + zy * zy) >= 4
xt = zx * zy
zx = zx * zx - zy * zy + cx
zy = 2 * xt + cy
i = i + 1
Cells(y, x).Interior.Color = VBA.RGB(10, 10, i * 10)
‘ my additional line to output X and Y and i values in each cell Cells(y, x).Value = x & "," & y & ",L" & i
To make a GDS of this I did it the long way in Excel where I got the X and Y co-ordinates and i as the layer then (in excel) defined each layer separately and copied and pasted about 40000 individual “cell.shapes” commands for each individual pixel (1um box).
# 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 # create a cell cell = layout.create_cell("TOP") # create a layer Layer1= layout.insert_layer(RBA::LayerInfo::new(1, 0)) Layer2= layout.insert_layer(RBA::LayerInfo::new(2, 0)) Etc … cell.shapes(Layer1).insert(RBA::Box::new(29,28,30,29)) cell.shapes(Layer1).insert(RBA::Box::new(30,28,31,29)) cell.shapes(Layer2).insert(RBA::Box::new(31,28,32,29)) cell.shapes(Layer2).insert(RBA::Box::new(32,28,33,29)) etc… 40000 times # 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.cell_index, 0) layout_view.add_missing_layers layout_view.zoom_fit
It worked but was quite a long process. (see attached image)
I tried using “while” function for the loop but I don’t know how to include the OR statement. I also have trouble defining the layer names i.e. Combining text “Layer” with variable (1) to make Layer1 etc.
Is there any possibility that you could convert the VB routine to Ruby?
Stretching my luck here: Is it also possible to write a Ruby routine that would enable me to merge each layer automatically so that I don’t have to manually view each one individually, select all then merge. i.e. loop that show each layer individually, select all, merge, unselect then move onto next layer.