Help with Ruby Programming

edited November 2015 in Ruby Scripting
Hello,

I have written the following code to generate a series of rings in different layers:

layout = RBA::Layout::new
layout.dbu = 0.001

layer = []
x=1
117.times {
layer_id= layout.insert_layer( RBA::LayerInfo.new(x,0) )
ln = RBA::LayerPropertiesNode::new
ln.width = 1
ln.source_layer_index = layer_id
layer.push( layer_id )
x+=1
}
layer.push(layer[116])
top_id = layout.add_cell("TOP")
top = layout.cell(top_id)

arr = []
q = 0
r=6432071.429.to_i
v=6425071.429.to_i
117.times {
arr[q]=(Math::sqrt((r^2)-(v^2)))*3614.45
v+=60
q+=1
}
arr[117]=0

x=0
117.times {
n = 20000 # number of points
r1 = arr[x] # radius 1
r2 = arr[x+1] # radius 2
da = 2 * Math::PI / n
hull_pts = n.times.collect { |i| RBA::Point.new(r1 * Math::cos(i * da), r1 * Math::sin(i * da))}
poly = RBA::Polygon::new(hull_pts)
hole_pts = n.times.collect { |i| RBA::Point.new(r2 * Math::cos(i * da), r2 * Math::sin(i * da))}
poly.insert_hole(hole_pts)
top.shapes( layer[x] ).insert( poly )
x += 1
}
layout.write("PROGRAM.dxf")


Is it possible for me to generate a similar series of rings at a different location in the same program?

For example, one location with the series as in the above program and another location with a series having a different number of rings?

Comments

Sign In or Register to comment.