Can't overwrite a layer in loop in drc

Hello,

I am trying to write a label to which I add more text time to time.
I use it as some kind of log. My goal is to have only one label at any point on this layer.

I realized that if I do this through a loop, the layer is not overwritten.
Below the code which is causing me some trouble:

# code block
for tm in ["A", "B", "C"]
    text = labels(60, 7).texts.data # I grab the content of the layer
    if text.count > 0 # I check if this is the first iteration
      text = text[0].string+tm+" generic\n"
    else 
      text = tm+" generic\n"
    end
    new_text = RBA::DText::new(text, 0, 0)  # Create my new text with more info
    new_label = labels() 
    new_label.data.insert(new_text)
    new_label.output(60,7) # here I overwrite the layer, but effectively, it just add one more label.
end

If I remove the loop and run the inner part many time, I get the behavior I want.
I can't understand why it's happening so far. Any idea ?

Regards,
Alexandre

Comments

  • I have not debugged the issue, but basically DRC is not made for dynamic output and input. Basically, DRC decks are made for having an input section, a processing section and an output section.

    So output does not necessarily create input for subsequent input layers. For example, if you use "target", the output layout space is a different one than input, so "output" does not send shapes to the same space that input takes it from. Apart from that, "output" does not overwrite, but add more shapes to the layer. This is what you see here.

    But I think the code is overly complex and congested. Why using a layer as an intermediate variable at all?

    So why no simply this:

    texts = []
    
    ... fill texts array with strings, i.e. texts << "Some Text"
    
    new_text = RBA::DText::new(texts.join("\n"), 0, 0)  # Create my new text with more info
    new_label = labels() 
    new_label.data.insert(new_text)
    new_label.output(60,7) # here I overwrite the layer, but effectively, it just add one more label.
    

    in other words: collecting texts and finally producing them once?

    Matthias

  • Hello Matthias,

    Thanks for your answer, it helps.
    You are right this piece of code is too complex for simply joining text together.
    I am actually doing more operations before this step inside the loop.
    The idea was to see where it breaks if it breaks. But you are right it might not be the best approach still.

    For some reason, adding this piece of code in the loop clear the layer.

        engine = DRC::DRCEngine::new
        engine.instance_eval("labels().output(60, 7)", '')
    

    Just to be sure, your second paragraph about input/output/target is in the context of loop only or is it also valid in general ?

    Best regards,
    Alexandre

  • Well, the output layer is initially cleared, when it is used the first time. Otherwise it would be quite confusing to always add to the output layer when you rerun the DRC script.

    So when you want to add to the output, you could keep the DRCEngine object somewhere and not create a new one.

    So the first time you do "output" in a DRCEngine object, the layer will be cleared. But every other call will add shapes. Like here:

    l1 = input(1, 0)
    l2 = input(2, 0)
    
    l1.sized(0.2.um).output(100, 0)
    l2.sized(0.2.um).output(100, 0)
    

    With this result:

    Matthias

  • Ok, thank you for your time.
    It helps.

    Regards,
    Alexandre

Sign In or Register to comment.