It looks like you're new here. If you want to get involved, click one of these buttons!
Playing with the tool this is a take on the Chop/Cut Etc
Draw a box , Draw a path, select the box then the path , run the script.
Plan is to make this where you select the box then draw the path
will automatically , tunnel through selected object.
# This script requires two selections
# * the first selection is the "subject" 
# * the second selection (Shift + click on object) is the "mask"
# The script will take all polygons from the subject and 
# separate it into parts inside and outside of the mask. 
# 
# TODO: 
# * as a side effect, the polygons are merged currently
#   (solution: pass them separately through the boolean operation)
# The Above has been implemented 
#Modifications 
#Tracy Groller
#2/10/21
#This Script is based on the Solution Matthias provided in January 2017 Klayout thread.
#https://www.klayout.de/forum/discussion/comment/4167#Comment_416744
#Modifications have been made too allow any layer too be used for the "Mask"
#Functionality is the same but you can use any "Dummy" layer as the "Mask" layer
#Select your "Dummy" Layer for the "Mask" this can be a "Box", "Path", "Polygon"
#Draw your "Dummy" layer over the selection then as above
# * the first selection is the "subject" 
# * the second selection (Shift + click on object) is the "mask"
#then run this "script"
#Will add functionality for "Menu" later
mw = RBA::Application::instance.main_window
lv = mw.current_view || raise("No layout loaded")
cv_index = nil
layer = nil
mask = RBA::Region::new
subjects = RBA::Region::new
shapes_to_delete = []
lv.each_object_selected do |obj|
  if obj.shape.is_box? || obj.shape.is_polygon? || obj.shape.is_path?
           poly = obj.shape.polygon.transformed(obj.trans)
           if obj.seq == 0
                 subjects += poly
                 layer ||= obj.layer
                  cv_index ||= obj.cv_index
           else
               mask += poly
         end
        shapes_to_delete << obj.shape
      end
end
layer || raise("No objects selected")
mask.is_empty? && raise("No mask objects selection (second selection)")
begin 
  #Boolean Function here for Chop
  value = RBA::InputDialog::ask_item("Boolean Functions", "Select one:", [ "Inside", "Outside", "And", "Or"], 0 )
  #puts(value)
  lv.transaction("Separate inside/outside of mask")
  inside  = subjects & mask
  outside = subjects - mask
  if value == "Inside" 
        lv.cellview(cv_index).cell.shapes(layer).insert(inside)
     elsif value == "Outside"
        lv.cellview(cv_index).cell.shapes(layer).insert(outside)
     elsif value == "And"
        lv.cellview(cv_index).cell.shapes(layer).insert(inside + outside)
     elsif value == "Or"
        lv.cellview(cv_index).cell.shapes(layer).insert(inside - outside)
  end
  shapes_to_delete.each do |s|
    s.delete
  end
  #outside.delete
ensure
  lv.commit
end
                
Comments
Thanks for sharing the code @tagger5896
Matthias,
Learning as I go , I know the chop cut functions already exist , but wanted too see if I
could roll my own.
Tracy