Path Merging and round end

edited October 2011 in KLayout Support
Hi Mathias,

Again, thanks for your soft. I'm using it to produce GDS for ebeam, and it works great.

I'm trying to script my GDS with ruby, and I actually have two questions.

*1*
First, is it possible to append two differents Path to have only one ?

For example, if I create two line like that :

-----------------------------------------------
def create_line( x1, y1, x2, y2, width)
point_list=[]
point_list.push(RBA::Point::new_xy(x1,y1))
point_list.push(RBA::Point::new_xy(x2,y2))
line = RBA::Path.new(point_list, width)
return line
end
line1 = create_line(-100000,0,0,0,2000)
line2 = create_line(0,0,100000,0,2000)
-----------------------------------------------

How can I merge them to end up with only one "line" Path object ?
I suppose I could do it at the point_list definition step, but it start to get messy it I add complex shape as bends, tapers and so on.

*2*
How to obtain round end with paths ? I tried:

line = RBA::Path.new(point_list, width,0,0,true)
and
line.round=true

but this is not working...

Many thanks !

Comments

  • edited October 2011

    Hallo,

    regarding the first question: a path can have as many points as you like, so its possible to use three points instead of just two and get a path that bends around a corner. Once you have a path object, it's not easily possible to connect two different objects. It's surely possible to do path merging on a abstract level, i.e. by describing the paths with special Ruby objects with support for concatenation and converting them to KLayout paths in a final step.

    Regarding the second question: unlike GDS, KLayout allows paths with round ends with an extension. However, extension 0 is equal to a flat end path, so those paths are not classified as round-ended ones.

    This should work:

    line = RBA::Path.new(point_list, width, width/2, width/2, true)
    

    BTW: for a similar reason it's not possible to define round-ended paths with a width of 0.

    Best regards,

    Matthias

  • edited November -1
    Hi Matthias,

    It's working perfectly, thanks.

    For now, I'm merging manually the differents shapes after generation, but I will look into Ruby to see if I can do it automatically.

    Regards,
  • edited November -1

    I am new to macro scripting and I want to draw path from a macro (generated from excel calculation). I don't understand the message error.

    <?xml version="1.0" encoding="utf-8"?>
    <klayout-macro>
    <description>bond path</description>
    <version/>
    <prolog/>
    <epilog/>
    <doc/>
    <format>general</format>
    <autorun>false</autorun>
    <autorun-early>false</autorun-early>
    <shortcut>Shift+T</shortcut>
    <show-in-menu>true</show-in-menu>
    <group-name/>
    <menu-path/>
    <interpreter>ruby</interpreter>
    <text>module bondpathMacro
    
    def bondpathMacro::create_line( x1, y1, x2, y2, width)
        point_list=[]
        point_list.push(Point::new_xy(x1, y1))
        point_list.push(Point::new_xy(x2, y2))
        line = Path.new(point_list, width)
        return line
    end
    
    create_line(14970, 18739, 8470, 18739, 20)
    create_line(14970, 18839, 8470, 18839, 20)
    create_line(14970, 19039, 8470, 19039, 20)
    create_line(14970, 18639, 8470, 18639, 20)
    create_line(14970, 18939, 8470, 18939, 20)
    create_line(14970, 19139, 8470, 19139, 20)
    create_line(14970, 16139, 8470, 16139, 20)
    create_line(14970, 16239, 8470, 16239, 20)
    create_line(14970, 15839, 8470, 15839, 20)
    create_line(14970, 16039, 8470, 16039, 20)
    create_line(14970, 15939, 8470, 15939, 20)
    create_line(14970, 15139, 8470, 15139, 20)
    create_line(14970, 15339, 8470, 15339, 20)
    create_line(14970, 15639, 8470, 15639, 20)
    create_line(14970, 15539, 8470, 15539, 20)
    create_line(14970, 15739, 8470, 15739, 20)
    create_line(14970, 15439, 8470, 15439, 20)
    create_line(14970, 15239, 8470, 15239, 20)
    create_line(14970, 14839, 8470, 14839, 20)
    create_line(14970, 14939, 8470, 14939, 20)
    create_line(14970, 15039, 8470, 15039, 20)
    create_line(14970, 14739, 8470, 14739, 20)
    
    end</text>
    </klayout-macro>
    
  • edited November -1

    Hi,

    first of all, I'd add 'include RBA' after the module command. That includes the RBA namespace and makes the classes (Point, Path) known to your module. You can also write "RBA::Point" or "RBA::Path" instead.

    Next, you'll have to specify what to do with the path object. If you want to put the path on the currently selected layer in the current cell, you'll have to use code like this:

    line = ...
    
    # current layout
    view = RBA::Application::instance.main_window.current_view.
    view || raise("No view open")
    
    # current layer and cell
    active_layer_node = view.current_layer.current
    layer = active_layer_node.layer_index
    cell = view.cellview(active_layer_node.cellview).cell
    
    # put the shape on the layer into the current cell
    cell.shapes(layer).insert(line)
    

    Matthias

Sign In or Register to comment.