XSection - Check if layer exists in If-Condition

Hello all,

I try to put an if condition in my XSection script and it works quite good. Is it possible to check within this condition if a special layer exists? I don't get this working for me.


BR, johannes


  • edited November 2022

    Maybe ... but "existance" of a layer is not a well-defined concept in GDS and OASIS. A layer does not exist if there is nothing drawn on it. So if you think of a technology option, that is not the right way to do that. A layout may be drawn without that layer, still it may want to use that tech option.

    Better include a boolean flag that you set externally.

    You can create a core.xs file that implements all options with if's, like this:

    if tech_option == "flash"
      # do the flash part ...

    and you create a top-level no_flash.xs file like this:

    tech_option = "no_flash"
    core_file = File.absolute_path("core.xs", File.dirname(@file_path))
    text = nil
    File.open(core_file) do |file|
      text = file.read
    if !text
      raise("Error reading file #{core_file}")
    eval(text, binding, core_file)

    and a similar file (`flash.xs') for the flash option:

    tech_option = "flash"

    So by running "no_flash.xs" you get the "no flash" option, with "flash.xs" you get the "flash" option.


  • Thank you very much for the detailed description. I will try this approach.


  • Hi,

    Here is an example which works for me. Not an exact if-condition but could be useful.

    layer_info1 = "8/0"
    layer_info2 = "9/0"
    @layout.layer_indices.each do |li|
        if (@layout.get_info(li).is_equivalent?(XS::string_to_layerinfo(layer_info1)))
            #do something1
            output("666", layer("8/0"))
        if (@layout.get_info(li).is_equivalent?(XS::string_to_layerinfo(layer_info2)))
            #do something2
            output("777", layer("9/0"))


  • @Grandement Thank you for sharing this!


Sign In or Register to comment.