A slice of pie for an arc

edited April 2016 in Ruby Scripting
I am trying to create and arc with outer diameter of 6.5µm and inner of 5.5µm with starting angle of 100 and ending of 280. I know that this is a built in function in KLayout. I need to draw some additional polygons and hence the code below.

I am getting the dreaded "No overload with matching arguments in Polygon::initialize" with the following code and I am lost....

I have also tried the line as:
ngpie = RBA::Region::new(pts)

and I get an error of "No overload with matching arguments in Region::initialize"

THE CODE

module MyMacro

include RBA
main_window = RBA::Application::instance.main_window
layout = main_window.create_layout(1).layout
layout_view = main_window.current_view
layout.dbu = 0.001
cell = layout.create_cell("MyLayout")
ng = layout.insert_layer(RBA::LayerInfo::new(8, 0))
ng1_r = 5500
ng2_r = ng1_r + 1000
ng1pt = RBA::Polygon::ellipse(RBA::Box::new(-ng1_r, -ng1_r, ng1_r, ng1_r), 100)
ng2pt = RBA::Polygon::ellipse(RBA::Box::new(-ng2_r, -ng2_r, ng2_r, ng2_r), 100)

pts = [0, 0]
n = 100
n.times do |i|
a = (100 + i.to_f * (180) / n) / 180.0 * Math::PI
pts << RBA::Point::new(ng2_r * Math::cos(a), ng2_r * Math::sin(a))
end
ngpie = RBA::Polygon::new(pts)
# cell.shapes(ng).insert(ngpie)

ngpt = RBA::Region::new(ng2pt) - RBA::Region::new(ng1pt) - RBA::Region::new(ngpie)
cell.shapes(ng).insert(ngpt)

layout_view.select_cell(cell.cell_index, 0)
layout_view.add_missing_layers
layout_view.zoom_fit

end

Comments

  • edited November -1

    Hi Vikas,

    just replace

    pts = [0, 0]
    

    with

    pts = [ RBA::Point::new(0, 0) ]
    

    Doing so makes the pts array a pure RBA::Point array and only such arrays are accepted as valid arguments for the polygon constructor.

    Matthias

  • edited November -1
    Thank you!!
Sign In or Register to comment.