Problem with Ruby scrip to generate GDS file

edited April 2011 in KLayout Support
Hi,

First, thanks for this program : I can *at last* work with GDS under my favorite OS. ;-)

I may have a beginner question, but I'm trying to generate a GDS file of donuts (for lithographic dose test purpose) using a ruby script. I'm new to ruby, but here is my script :
http://darckense.online.fr/data/create_donnuts_v1.rb

I launch it using : klayout -r create_donnuts_v1.rb

and when I want to save the file, I have this error message in the console :

[darckense@rose ruby]$ klayout -r create_donnuts_v1.rb
(12042) KSycocaPrivate::openDatabase: Trying to open ksycoca from "/var/tmp/kdecache-darckense/ksycoca4"
kfilemodule(12042)/kdecore (services) KMimeTypeFactory::parseMagic: Now parsing "/usr/local/share/mime/magic"
kfilemodule(12042)/kdecore (services) KMimeTypeFactory::parseMagic: Now parsing "/usr/share/mime/magic"
kfilemodule(12042)/kdecore (services) KMimeTypeFactory::parseMagic: Now parsing "/home/darckense/.local/share/mime/magic"

The saved GDS file is empty. It could be downloaded here :
http://darckense.online.fr/data/donnuts.gds

I'm certainly doing something wrong in the way I generate GDS file, but I cannot figure it out.

Does anyone have an idea ?

Thanks.

Edit: Sorry, I uploaed the wrong script... now, there is the good one. Thanks again. :)

Comments

  • edited April 2011

    Hi izard,

    Thanks for providing the script - debugging is much easier with a real example :-)

    What is basically missing in your script is the assignment of the layer and datatype when the layer is created. Without that information, KLayout doesn't know where to save the layer and simply omits it. I admit that is a somewhat disrespectful, but the idea behind that is to allow temporary layers which are not saved.

    To fix that part of the problem you simply need to tell the LayerInfo object the layer and datatype. Both numbers specify which GDS layer to use. In order to supply the layer, you could add two arguments to the "gen_layer" function.

    In addition, you will notice, that the layers are shown as "%..." in the layer list. That is because the layers where specified by layer index in the LayerPropertiesNode. I should explain the idea behind the layer list: it is basically a set of views to the layers rather that kind of pointers. If a certain GDS layer is to be shown, the view needs to know the layer and datatype of the layer to show. This way the view selects the layer by layer and datatype rather than by index (that is basically what the % says). Basically that does not make a big difference, but usually people prefer to think of GDS layers and datatypes rather than indexes.

    The modified "gen_layer" function is here:

    def gen_layer(l, d)
      layer = RBA::LayerInfo.new
      # New: specify layer and datatype into which to save the layer
      layer.layer = l
      layer.datatype = d
      layer_index = $layout.insert_layer( layer )
      layer_node = RBA::LayerPropertiesNode::new
      layer_node.dither_pattern = 5
      layer_node.fill_color = 0xff00ff
      layer_node.frame_color = 0xff00ff
      layer_node.width = 1
      # New: specify layer and datatype rather than index
      layer_node.source_layer = l
      layer_node.source_datatype = d
      $view.insert_layer( $view.end_layers, layer_node )
      return layer_index
    end
    

    Provided your intention is to assign different layers, you also have to modify the call of that function:

    for j in 0...20
      gen_line(j*40000, gen_layer(j + 1, 0))
    end
    

    This will assign GDS layers 1 to 21 to the different shapes.

    Hopefully that explanation makes some things clearer.

    Best regards,

    Matthias

  • edited November -1
    Dear Matthias,

    Thank you so much for your reactivity.
    Yes, your explanations are perfectly clear about the layers. Now everything works perfectly.

    Thank you again,

    Best Regards,
  • edited November -1
    Thanks to both of you for this nice scripting example. This is similar to some tasks I want to do, and this script provides a nice starting point.
Sign In or Register to comment.