Placing Pcell "ROUND_PATH" instances with Ruby script

Hi Matthias,

I would like to instantiate the Basic "ROUND_PATH" Pcell with different parameter values by script (Ruby). How do I refer to the (internal) parameter names of the Pcell (in the "PCell parameters" tab they are called "Layer", "Radius" and "Number of points / full circle.")?

Thanks in advance.

Cheers,

Tomas

Comments

  • edited October 2019

    Hi Thomas,

    here is a little script which you can apply to any PCell to get it's details:

    lib = RBA::Library::library_by_name("Basic")
    pcell_decl = lib.layout.pcell_declaration("ROUND_PATH")
    
    type2strings = {}
    
    [ :TypeBoolean, :TypeDouble, :TypeInt, :TypeLayer, :TypeList, :TypeNone, :TypeShape, :TypeString ].each do |t|
      type2strings[RBA::PCellParameterDeclaration::class_eval(t.to_s)] = t.to_s
    end
    
    # Dump parameter information
    pcell_decl.get_parameters.each do |pd|
      puts("Parameter: " + pd.name)
      puts("  Description: " + pd.description.to_s)
      puts("  Default: " + pd.default.to_s)
      puts("  Hidden: " + pd.hidden?.to_s)
      puts("  Readonly: " + pd.readonly?.to_s)
      puts("  Type: " + type2strings[pd.type])
      puts("  Unit: " + pd.unit.to_s)
      if pd.choice_values.size > 0
        puts("  Choices:") 
        pd.choice_values.each_with_index do |c,i|
          puts("    Value/Description: " + c.to_s + "/" + pd.choice_descriptions[i].to_s)
        end
      end
    end
    

    In the case of the ROUND_PATH PCell it will print:

    Parameter: layer
      Description: Layer
      Default: 
      Hidden: false
      Readonly: false
      Type: TypeLayer
      Unit: 
    Parameter: radius
      Description: Radius
      Default: 0.1
      Hidden: false
      Readonly: false
      Type: TypeDouble
      Unit: micron
    Parameter: path
      Description: 
      Default: (0,0;0.2,0;0.2,0.2) w=0.1 bx=0 ex=0 r=false
      Hidden: false
      Readonly: false
      Type: TypeShape
      Unit: 
    Parameter: npoints
      Description: Number of points / full circle.
      Default: 64
      Hidden: false
      Readonly: false
      Type: TypeInt
      Unit: 
    

    Kind regards,

    Matthias

  • Hi Matthias,

    Thank you for the code above. I'm struggling now to set the "path" parameter:

    1) param = { "layer" => RBA::LayerInfo::new(4, 0), "radius" => 0.2, "npoints" => 16 }

    This works fine but it uses the default path guiding shape ((0,0;0.2,0;0.2,0.2) w=0.1).

    2) I don't get how to set the "path" parameter, I tried:

    path_points = [Point.new(0,0), Point.new(20000,0), Point.new(20000,20000)]
    path_width = 2000
    path = Path.new(path_points, path_width)

    param = { "layer" => RBA::LayerInfo::new(4, 0), "radius" => 5.0, "npoints" => 16, "path" => path}

    The guiding shape is drawn as intended ((0,0;20.0,0;20.0,20.0) w=2.0), but no rounded path is generated on layer 4/0.

    Cheers,

    Tomas

    PS: Is it possible to do the "Edit > Selection > Convert to Pcell" command by scripting?

  • Hi Thomas,

    Well ... there is a pitfall.

    Please you a DPath object with Micrometer values instead. So that would be

    path_points = [DPoint.new(0,0), DPoint.new(20,0), DPoint.new(20,20)]
    path_width = 2
    path = DPath.new(path_points, path_width)
    
    param = { "layer" => RBA::LayerInfo::new(4, 0), "radius" => 5.0, "npoints" => 16, "path" => path}
    

    (small disclaimer: not tested). The idea of parameters is that they are independent from the layout details - specifically the DBU. Hence: LayerInfo instead of layer index, radius in micrometers instead of DBU and path in micrometer units instead of DBU. This applies to all shape types (DPolygon, DBox).

    You see from the Default path that it's a µm version: "Default: (0,0;0.2,0;0.2,0.2) w=0.1 bx=0 ex=0 r=false".

    I wasn't aware that the guiding shape is still drawn properly ...

    Kind regards,

    Matthias

  • P.S. "convert to PCell" is partially covered by PCellDeclaration#parameters_from_shape. But still you have to delete the shape and insert the PCell instance yourself.

  • Hi Matthias,

    Thanks for the info! Works like a charm now. :-)
    Would you advise to update "old" (but still working) code (for instance made before DCellInstArray was introduced)?

    Kind regards,

    Tomas

  • edited October 2019

    Hi Tomas,

    You mean to keep the integer-unit objects such as Box, CellInstArray when working with the database API?

    I'll keep the integer-unit objects forever, so you don't have to update :-)

    Seriously, the integer-unit objects are somewhat more stable as no floating-point rounding issues are involved. So it makes sense to keep them.

    Kind regards,

    Matthias

Sign In or Register to comment.