Using TextGenerator in Python

edited July 2018 in Ruby Scripting

Hi All,

I'm trying to label my shapes in the gds and came across the TextGenerator class. However, it's not clear to me how this works.

I tried:

gen = pya.TextGenerator()
gen.default_generator()
region = gen.text("A TEXT", 0.001)
top.shapes(layer).insert(region)

But the layer doesn't show any text. What am I doing wrong?

I tried this approach because the whole PCell.TEXT stuff seems overly complicated (and I haven't been able to get it to work in Python, either).

Edit: Sorry, first time user here. Could somebody please move this to the Python forum?

Comments

  • Hi,

    sorry - I just noticed the documentation for this class is broken.

    The solution is:

    region = pya.TextGenerator.default_generator().text("A TEXT", 0.001)
    

    "default_generator" is a class method ("static" in C++ slang). It delivers a text generator with the standard font.

    Matthias

  • Thanks a lot Matthias. That way it works perfectly.

    Also, many thanks for the time and effort you put into this nice and very useful tool.

    Patrick

  • excuse me, how can i put labels and lengths on my shapes automatically when ever i changed the values in the interface_

Sign In or Register to comment.