path with variable width

edited April 2014 in KLayout Support
Hi,

Is it possible to write path with variable widths? For example, I want one extreme of the path to be 30 um wide and the other to be 5 um, with a progressive variation. This looks like the "Path" edit tool --> extension "Variable", but it simply ignores the "start" and "end" values when I draw, considering only the "Width" field. This results in a path with constant width. I use KLayout 0.22.9 under Linux Mint Debian.

Thank you for your help and attention.
Cheers,
Alexandre.

Comments

  • edited November -1

    Unfortunately I don't think so. Paths are by definition two things: a set of points defining the "hull" and a (single-number) width.

    You will have to draw it as a polygon, I think..

    Here is a script I wrote to draw a PCell polygon -- you can modify it to draw whatever taper shape you like. Then it can be called either via script or just by clicking the "Instance" button then modifying the xy coords.

    module PCell_Poly
    
      include RBA
    
      # Remove any definition of our classes (this helps when reexecuting this code after a change has been applied)
      PCell_Poly.constants.member?(:PCell_Poly) && remove_const(:PCell_Poly)
      PCell_Poly.constants.member?(:MyLib) && remove_const(:MyLib)
    
      # The PCell declaration for the circle
      class PCell_Poly < PCellDeclarationHelper
    
        include RBA
    
        def initialize 
          super
    
          # Declare the params. One of them must be a TypeLayer called "l" (or if called something else, then "l_layer" below needs to also be modified
          param(:x, TypeList,  "List of x coords", :default => ["0","0","10","10"])
          param(:y, TypeList,  "List of y coords", :default => ["0","10","10","0"])
          param(:l, TypeLayer, "Layer", :default => LayerInfo::new(1,0))
        end
    
        def display_text_impl
          "POLY"
        end
    
        def coerce_parameters_impl
          # CODE
        end
    
        def can_create_from_shape_impl # Needs to return true or false based upon analysis of the input shape "shape"
          false
        end
    
        def parameters_from_shape_impl # Needs to call the set_x methods, where x is the shape parameters, to set the parameters for shape "shape"
        end
    
        def transformation_from_shape_impl # Needs to return a transformation for the final PCell based on the original shape "shape"
        end
    
        def produce_impl # This is the main part of the implementation -- into cell "cell" using layer "l_layer", insert the desired shapes
          # Fetch the params
          x_list = x
          y_list = y
    
          # Compute stuff, if needed
          x_list.map! { |v| eval(v) }
          y_list.map! { |v| eval(v) }
          xy_list = [x_list, y_list].transpose # Concatenate the two arrays so you get something like [[0, 0], [0, 10], [10, 10], [10, 0]]
          pts = []
          dbu = layout.dbu
          xy_list.each { |xy|
            xx = xy[0]
            yy = xy[1]
            pts.push(RBA::Point.new(xx/dbu,yy/dbu))
          }
          # Lastly, create the shape
          cell.shapes(l_layer).insert(Polygon.new(pts))
          layout_view = RBA::Application.instance.main_window.current_view
          layout_view.add_missing_layers
        end
    
      end
    end
    

    Note that I use the following separate .lym file with the "Run on startup" selected, to register this PCell (and others) on startup.

    module InitializeLibs
    
      # The library where we will put the PCell into 
      class MyLib < RBA::Library
    
        def initialize  
    
          self.description = "Description"
    
          load File.expand_path('filepath/PCell_Poly.rb')
    
          # PCell declarations
          layout.register_pcell("PCell_Poly", PCell_Poly::PCell_Poly::new)
    
          register("MyLib")
    
        end
      end
    
      # Instantiate and register the library
      MyLib::new
    
    end
    
  • edited November -1

    BTW I believe "extension" for a path is not the width at start and end, but a measure of how far beyond the start and end the path is drawn.

    For example, zero extension means the path terminates exactly at the x and y location specified. Nonzero extension (on the start or end) means the path extends a little beyond what was specified for the start or end.

  • edited April 2014
    Hi david234589,

    Thank you very much for your help with the script code and the elucidation about the "path variable" extension. I will try to work on the code and check the possibility of adapting it for my needs.

    Thanks again!
    Bye!
  • edited November -1

    Note that PCell may be overkill, depending on what you are trying to do. If you just want to draw a polygon you could just use ruby script to draw a polygon. I guess my larger point was that a path won't work here, you need to draw a polygon.

  • edited November -1
    Yes, I understand. I haven't yet had time to try it, but thank you for your comment!
Sign In or Register to comment.