merge path

edited June 2016 in General

Hi Matthias,

Would it be possible to add a feature to merge paths together? Namely, if I draw one path, I would like the ability to extend it (assuming the same widths). You already have a "merge" mode in the toolbar, but when we draw paths using the "merge" mode, they get converted to polygons.

Thank you
Lukas

Comments

  • edited November -1

    Hi Lukas,

    Maybe here is a script which does what you want: it will selected paths and join them by concatenating the segments. I guess handling of end and start extensions and redundant points is missing but it may serve as a staring point:

    mw = RBA::Application::instance::main_window
    view = mw.current_view
    
    begin
    
      view.transaction("Merge paths")
    
      new_path = nil
    
      sel = view.object_selection
      new_sel = []
      to_delete = []
    
      sel.each do |s|
        if !s.is_cell_inst? && s.shape.is_valid? && s.shape.is_path?
          if !new_path
            new_path = s.shape.path
            new_sel << s
          else
            pts = []
            new_path.each_point { |p| pts << p }
            s.shape.path.each_point { |p| pts << p }
            new_path.points = pts
            s.shape.shapes.erase(s.shape)
          end
        end
      end
    
      if new_path
        new_sel[0].shape.path = new_path
      end
      view.object_selection = new_sel
    
    ensure
      view.commit
    end
    

    Matthias

Sign In or Register to comment.