Refer to a layer by its GDS number

edited July 2013 in General

Hi,

I use this to write something on the third layer listed in the "Layers" list at the right of the screen:

out_layer = 3;
myEP = RBA::EdgeProcessor::new
myEP.boolean_p2p([ first.polygon ], [ second.polygon ], RBA::EdgeProcessor::ModeANotB, false, false)
myEP.each do |p|
    out_cell.shapes(out_layer).insert(p)
end

Now, what if I want to write to GDS Layer Number 6? If there are five layers specified before that then I can just replace the "3" with "6" and done. However if there are fewer than five layers before layer 6 appears in the list, and I don't know how many layers there will be in a given file, how do I always refer to GDS Layer 6?

Seems like it'd make more sense to use the GDS number rather than the order it appears in the layers list, to refer to layers?

Comments

  • edited July 2013

    Never mind, figured it out!

    For any future readers interested, here is how I did it:

    layernum = 6
    datatypenum = 0
    out_layer = layout.layer_indices.find do |li|
        info = layout.get_info(li)
        info.layer == layernum && info.datatype == datatypenum
    end
    

    The resulting layer index is saved in out_layer.

    Seems a little strange that there doesn't appear to be a ruby method to do this - but I guess it's not hard to write the five lines above..

    Also I just realized I am miscategorizing my questions - in General rather than Ruby Scripting. Sorry I'm new here, I'll try to put them in the correct category in the future.

  • edited July 2013

    Hi David,

    thanks for sharing this information with us. You're right - it is strange that there is no method for this yet. But the good news is there will be one in the next major release: Layout#find_layer will exactly do the above.

    And one more brief remark: A slightly more elegant way to write the above loop is:

    target = RBA::LayerInfo::new(6, 0)
    out_layer = layout.layer_indices.find { |li| layout.get_info(li).is_equivalent?(target) }
    

    If you want to create the layer if it is not there yet, you can add this line too:

    out_layer ||= layout.insert_layer(target)
    

    Regards,

    Matthias

Sign In or Register to comment.