Support Forum

Issues implementing booleanTool in Python


Sunday 1st October 2023
(only for registered users)

Screenshot 2023-10-01 at 4.21.41 PM.png

Hello, I am new to using the python scripting feature in LayoutEditor. I am trying to conduct boolean operations on different layers within a cell. As a simplified test I have written the following, which is meant to add box1 and box2 on the active layer. ``` #create a new layout object l=project.newLayout(); dr= l.drawing c=dr.addCell().thisCell layer1 = 1 layer2 = 2 box1 = c.addBox(0,0,500,500,layer1) box2 = c.addBox(-100,-100,500,500,layer2) l.booleanTool.addLayerA(layer1) l.booleanTool.addLayerB(layer2) l.booleanTool.aPlusB() ``` I have not been able to get this to work. The script executes correctly and then I open the .gds file and I have two boxes but no operation has been completed on them. I have also tried using `boolOnLayer` as well as implementing `booleanHandler`. I have the full version of LayoutEditor. Any help would be greatly appreciated!
Wednesday 4th October 2023
Please replace the third line (```c=dr.addCell().thisCell```) with ```c=dr.currentCell``` Any new drawing will already contains an empty cell and this cell is set as current cell. With your line ```c=dr.addCell().thisCell``` you will add a second empty cell to the design and add the boxes to this cell. However, the booleanTool will work on the current cell, which is the another cell and is empty. So it has no effect. Alternative adding a line ```dr.setCell(c);``` before the booleanTool command will have the same effect. The boolean operation will work on your new created cell.