Support Forum

Rotation 90° (Python Script)

Eva

Thursday 30th June 2022
Good morning, I would like to rotate my draw. I used the function dr.rotate(90) in the follow script : ``` 1 import LayoutScript 2 from LayoutScript import * 3 4 # automatic labeling of an array 5 6 7 l=project.newLayout(); 8 9 dr=l.drawing # pointer to the main drawing 10 11 dr.currentCell.cellName="python_example_label" 12 13 dr.clearPoints() 14 15 16 17 for x in range (0,10): 18 for y in range (0,10): 19 dr.point(x*1800,y*800) 20 dr.text("#"+str(x)+"/"+str(y)) 21 22 23 24 dr.selectAll() 25 dr.setWidth(400) 26 dr.toPolygon() 27 dr.deselectAll(); 28 29 # writes result to the home folder 30 31 import os 32 l.drawing.saveFile( os.path.expanduser('~')+"/testout.gds") 33 34 35 print ("Python script completed" ) ``` It doesn't work. Nothing happen. Do you know how can I do that ? Best Regards, Eva
Jürgen
LayoutEditorFull
Thursday 30th June 2022
Der *rotate* function `dr.rotate(90)` will need the origin of the rotation first: ```Python ... dr.selectAll() dr.setWidth(400) dr.toPolygon() dr.point(0,0) # rotated around the point (0,0) dr.rotate(30) # perfom the rotation around the previous entered point dr.deselectAll() ... ```
Eva

Thursday 30th June 2022
It works ! Thank you very much ! Eva