Support Forum

Cut command in a macro causes different results

GT

Monday 18th July 2022
Attachments:
(only for registered users)

cut_bug1.png

Hi! Please take a look at the attached macro. Why does the first cut() command cut the square box into three pieces, but not two? Thanks!
Jürgen
LayoutEditorFull
Tuesday 19th July 2022
Thanks for mentioning this issue. These was an issue with the cut feature in case the cut line ends or start exactly on a corner of a polygon. Then in some cases the cut operation results in one addition piece. This issue is fixed in the current development release (20220718 or newer), download with this link: https://layouteditor.com/download?release=latest If this release does not fix the issue, please send me exact coordinates you have used. We will review it once more.
GT

Tuesday 26th July 2022
Attachments:
(only for registered users)
 cut_bug3.gds

cut_bug3.png

The 20220718 version did fix the previous problem. However, there is another bug from this cut() command even using this new release. Please see the attached GDS file, picture, and macro. Open the GDS file first and investigate the waveguide structures marked 1, 2, 3, 4 in the picture. Zoom into the waveguide at area-1 and you'll see a small section that I want to cut out as "FK-polygon". The 8 coordinates of this FK-polygon is given in the macro as reference. In the original GDS file, this structure is repeated drawn in area 1, 2, 3, 4. They are separated by exactly 750um in X-direction. My goal is to cut the four FK-polygons out of the original design and move them into a different layer. So I define two cut lines and use a for-loop in the macro to execute the cut() command for this purpose. Now please run the macro and you'll see the problematic results. The "FK-polygons" at area 2 and 4 are correctly cut and separated, but there are additional polygons mistakenly added at area 1 and 3. Please fix this problem for me. Thanks!
Jürgen
LayoutEditorFull
Tuesday 26th July 2022
Can you send me the macro as well? I guess you need to copy&past it into the forum text as macro attachments are not supported. Are you aware that in you design any of the waveguides is draw twice with identical polygons over each other. So if you select one and cut it, there will still be an original polygon below it. This polygon was not select and so not cut at the entered line.
GT

Wednesday 27th July 2022
Oh, I didn't know macro file cannot be attached. Here are the codes. #!/usr/bin/layout #name=cut_bug3 /* ----------------------------------------------------------------------------------- Channel-1 and Channel-3 always have problem after cut() operation!? ------------------------------------------------------------------------------------*/ int main() { // ----- open the GDS file string f1_name="cut_bug3.gds"; layout->open(f1_name); layers::enableAllLayer(); layout->drawing->activeLayer=10; int i, j, k; double channel_dx = 750.0 ; // An FK waveguide consists of 8 points. These coordinates are from the lower-left unit. double FK_wg_x1 = 1100.272 , FK_wg_y1 = 7975.749 ; double FK_wg_x2 = 1099.726 , FK_wg_y2 = 7974.249 ; double FK_wg_x3 = 1105.000 , FK_wg_y3 = 7975.500 ; double FK_wg_x4 = 1105.000 , FK_wg_y4 = 7974.500 ; double FK_wg_x5 = 1145.000 , FK_wg_y5 = 7975.500 ; double FK_wg_x6 = 1145.000 , FK_wg_y6 = 7974.500 ; double FK_wg_x7 = 1149.727 , FK_wg_y7 = 7975.749 ; double FK_wg_x8 = 1150.273 , FK_wg_y8 = 7974.249 ; // These coordinates are from the lower-left unit (see the PPT for explanation). double cut_x1 = 1100.546 , cut_y1 = 7976.500 ; double cut_x2 = 1099.454 , cut_y2 = 7973.500 ; double cut_x3 = 1149.454 , cut_y3 = 7976.500 ; double cut_x4 = 1150.546 , cut_y4 = 7973.500 ; for (j=0; j<4; j++) { // The second cut always create problem at channel 1 and 3!!!? layout->drawing->p(FK_wg_x1+(channel_dx*j), FK_wg_y1); layout->drawing->fSelect(); layout->drawing->p(cut_x1+(channel_dx*j), cut_y1); layout->drawing->p(cut_x2+(channel_dx*j), cut_y2); layout->drawing->cut(); layout->drawing->deselectAll(); layout->drawing->p(FK_wg_x8+(channel_dx*j), FK_wg_y8); layout->drawing->fSelect(); layout->drawing->p(cut_x3+(channel_dx*j), cut_y3); layout->drawing->p(cut_x4+(channel_dx*j), cut_y4); layout->drawing->cut(); layout->drawing->deselectAll(); } } // end of main()
GT

Wednesday 27th July 2022
Oh, I didn't know macro file cannot be attached. Here are the codes. ``` #!/usr/bin/layout #name=cut_bug3 /* ----------------------------------------------------------------------------------- Channel-1 and Channel-3 always have problem after cut() operation!? ------------------------------------------------------------------------------------*/ int main() { // ----- open the GDS file string f1_name="cut_bug3.gds"; layout->open(f1_name); layers::enableAllLayer(); layout->drawing->activeLayer=10; int i, j, k; double channel_dx = 750.0 ; // An FK waveguide consists of 8 points. These coordinates are from the lower-left unit. double FK_wg_x1 = 1100.272 , FK_wg_y1 = 7975.749 ; double FK_wg_x2 = 1099.726 , FK_wg_y2 = 7974.249 ; double FK_wg_x3 = 1105.000 , FK_wg_y3 = 7975.500 ; double FK_wg_x4 = 1105.000 , FK_wg_y4 = 7974.500 ; double FK_wg_x5 = 1145.000 , FK_wg_y5 = 7975.500 ; double FK_wg_x6 = 1145.000 , FK_wg_y6 = 7974.500 ; double FK_wg_x7 = 1149.727 , FK_wg_y7 = 7975.749 ; double FK_wg_x8 = 1150.273 , FK_wg_y8 = 7974.249 ; // These coordinates are from the lower-left unit (see the PPT for explanation). double cut_x1 = 1100.546 , cut_y1 = 7976.500 ; double cut_x2 = 1099.454 , cut_y2 = 7973.500 ; double cut_x3 = 1149.454 , cut_y3 = 7976.500 ; double cut_x4 = 1150.546 , cut_y4 = 7973.500 ; for (j=0; j<4; j++) { // The second cut always create problem at channel 1 and 3!!!? layout->drawing->p(FK_wg_x1+(channel_dx*j), FK_wg_y1); layout->drawing->fSelect(); layout->drawing->p(cut_x1+(channel_dx*j), cut_y1); layout->drawing->p(cut_x2+(channel_dx*j), cut_y2); layout->drawing->cut(); layout->drawing->deselectAll(); layout->drawing->p(FK_wg_x8+(channel_dx*j), FK_wg_y8); layout->drawing->fSelect(); layout->drawing->p(cut_x3+(channel_dx*j), cut_y3); layout->drawing->p(cut_x4+(channel_dx*j), cut_y4); layout->drawing->cut(); layout->drawing->deselectAll(); } } // end of main() ```
Jürgen
LayoutEditorFull
Wednesday 27th July 2022
Attachments:
(only for registered users)

Screenshot_20220727_212850.png

You design contains several tiny steps like this one: ![Screenshot_20220727_212850.png](/api/img.php?thread=20220718-f3ba&file=Screenshot20220727212850.png) These step are causing your issue. I recommend to merge all waveguide shapes in the first step to remove any double covered area and then call *shape utilities/remove small edges* with an value of 2nm to remove these tiny steps. Then your macro will run without the issue.
GT

Wednesday 27th July 2022
Got it. My codes work as expected after removing the duplicate points now. Is there any warning that one can set up for LayoutEditor to notify users about duplicate structures like my example? Thanks for your help!
Jürgen
LayoutEditorFull
Wednesday 27th July 2022
There are features to detect it like the DRC check *Overlapping Elements* and feature to remove it like *Strip Identical Elements*. But there is no possibilities for an automatic check as any automatic check will slow down the performance in particular for bigger designs.