RBA GDS2 layer parameter modification

edited November 2010 in KLayout Support
Hello,

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

Jean-Yves

Comments

  • 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
      l.next
    end
    

    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
      l.next
    end
    

    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,

    Matthias

  • edited November -1
    Hi Matthias,

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

    Jean-Yves
Sign In or Register to comment.