How to change the number of points or angular resolution of a arc when using python code to generate GDS files?
Zhi LayoutEditorFull Thursday 6th February 2025
Hi,
I have a question about using python code to generate arc shapes. I am using this command "c.addPolygonArc" to generate some arcs. However, I find that the number of points is not enough which makes the shape not smooth. Do you know how to solve this issue?
Thanks.
Jürgen LayoutEditorFull Thursday 6th February 2025
Hi,
the class setup has a member circularDefault. This value influence for all circular/arc operations the density on points. A value of 5 will add one point per 5deg or 360/5=72 points per circle. This value eeds to be changed before the arc/polygon is created.
Next to this default value there is a feature to detect arcs and circles and increase or decrease the number of points there. This feature is called *bow improvement* and in the user interface located under shape utilities. In the scripting interface it is located in the class *cell* as [bowImprovmentSelect](https://layouteditor.org/layoutscript/api/cell#23)
Zhi LayoutEditorFull Thursday 6th February 2025
Thanks so much!! I really appreciate it!!
Could you please show me how to use them, circularDefault and bowImprovmentSelect? I have tried to use them but there were some errors I don't know how to solve.
Please see the attachment which is a python code for generating a Arc shape.
Zhi LayoutEditorFull Thursday 6th February 2025
import LayoutScript
from LayoutScript import *
l=project.newLayout();
layers.num(6).name="new text"
c=l.drawing.currentCell
c.cellName="test-cell-python"
c.addPolygonArc(point(0,0),48,52,0,90,5)
import os
l.drawing.saveFile( os.path.expanduser('~')+"/testout.gds")
#l.drawing.saveFile("/Users/apple/testout.gds")
print ("Python test completed" )
Jürgen LayoutEditorFull Sunday 9th February 2025
Please be aware, that the radius in the addPolygonArc command is in database units. So you arc will be very small in the range of the resolution of the design. Such arc will always look ugly as an vertex need to be in the database grid.
A setting of the 'circularDefault' can be set like this:
```python
import LayoutScript
from LayoutScript import *
l=project.newLayout();
SetUp=setup() # work around as static string variables are not handled correctly
SetUp.set("circularDefault","1");
layers.num(6).name="new text"
c=l.drawing.currentCell
c.cellName="test-cell-python"
c.addPolygonArc(point(0,0),48000,52000,0,90,5)
import os
l.drawing.saveFile( os.path.expanduser('~')+"/testout.gds")
print ("Python test completed" )
```
Zhi LayoutEditorFull Sunday 16th February 2025
Thanks so much! Problem solved.