Simple import text.txt files of polygon co-ordinates


Thanks for this design program it is a huge help to my studies.

I have a lot (100's - 1M's) of text.txt files which contain the tab delimited x,y co-ordinates of polygons. Is there a simple way to read all of these text.txt files in without any understanding of Ruby or Python (Python I have a little understanding but I would like to avoid Macro editing if possible) and make the shapes.

Many Thanks,



  • Hi Tom,

    I'm sorry, but this is exactly the thing Ruby or Python was made for.

    You can essentially edit a drawn polygon coordinates in a text edit box. You could paste the coordinates from one Polygon into this box so make the polygon look like the one you want to have. But I think you'll want a script that reads all your files and turns them into polygons.

    I can give you a skeleton of such a script:

    # Assume we have a layout loaded and a layer - let's say layer 1, datatype 0 - is prepared to 
    # receive the polygons ...
    ly =
    layer = ly.layer(1, 0)   # layer 1, datatype 0
    shapes = ly.top_cell().shapes(layer)
    # assuming files is an array containing all your file names, and read_file is a function which reads
    # a file and returns an array of coordinates [ [x,y], ... ] 
    for f in files:
      points = read_file(f)
      polygon = pya.DPolygon([ pya.DPoint(p[0], p[1]) for p in points ])


  • Thanks Matthias. I will look to understand the programmatic coding.

Sign In or Register to comment.