Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

RBA GDS2 layer parameter modification

edited November 2010 in KLayout Support

I've to developp a Ruby script in order to change layer parameters or layer views from a GDS2 file. I use first the begin_layer/end_layer instruction to iterate a read loop on all layers. When I try to modify the visible state or only the name of the current layer (Class LayerPropertiesNode), Klayout displays an error message (a conflict with Const Ref for example when visible=true). How to do that with a RBA script for a pre-existing layer ?
Thanks for your answer



  • edited November 2010

    Hi Jean-Yves,

    I assume you are trying to do something like that:

    v = ... # get RBA::LayoutView
    l = v.begin_layers
    while !l.at_end?
      l.current.visible = true

    This will fail because "l.current" is basically just a pointer to an internal structure and it is not allowed to directly modify this structure. Hence the pointer is "const" meaning it cannot be modified.

    To solve that problem, the code needs to be rewritten like that:

    v = ... # get RBA::LayoutView
    l = v.begin_layers
    while !l.at_end?
      p = l.current.dup              # create a new copy which can be modified
      p.visible = true               # modify the visibility
      v.set_layer_properties(l, p)   # install the new layer properties

    I admit that is not very intuitive but this scheme is a tribute to the linking of ruby's dynamic objects with static C++ structures. BTW this scheme is used in different places, i.e. for the modification of geometrical properties of shapes.

    Hopefully that helps.

    Best regards,


  • edited 4:14AM
    Hi Matthias,

    your code suits me perfectly. Thank you for yout help.

Sign In or Register to comment.