It looks like you're new here. If you want to get involved, click one of these buttons!
Related to this question, there must be a scripting way to iterate through all the vertices of a polygon and a) print them out, or b) delete some of them to clean up a design if they meet certain conditions (eg, if N of them are in a very straight line only the endpoints need to be kept), or c) snap them to a grid if X or Y are within distance D of the grid, etc.
Also, can this iteration be done over all the polygons in the layer?
Is there an example of a script like this (in Python or Ruby) that I can use to get started?
Thanks in advance,
Rick
Comments
Here's a starting point. Click on the polygon and run this script in the IDE (press F5 to get the IDE). It simply grabs the points of the polygon. The other functions you mention are certainly possible. For (b), I'd make an array of the xy coordinates, delete one, then make a NEW polygon and write it to the layout. For (c) similarly.
Thanks David,
That is a great starting point. Examples for Klayout was a great help, also. Item b) is almost working.
Note to self: this code is Ruby, not Python. Fine - I'm learning two languages for the price of one!
Rick
Hi David,
I noticed the "Examples" first time now ... great thing! Thanks a lot!
Matthias