Vincent Dansereau Vincent Dansereau - 1 year ago 151
Ruby Question

Error using method edges.each |edge|

I typed this from a tutorial in Sketchup Ruby API.

centerpoint = Geom::Point3d.new(0,0,0)
vector = Geom::Vector3d.new 0,0,1
model = Sketchup.active_model
entities = model.active_entities
eges = entities.add_circle( centerpoint, vector, 10)
vertices = []
edges.each do |edge|
vertices << edge.start
vertices << edge.end
end
vertices.uniq!
vertices.each do |vert|
entities.add_cpoint(vert.position)
end


I get this error message.

Error: #<SyntaxError: <main>: syntax error, unexpected end-of-input
edges.each do |edge|
^>


I would like to know why.

Answer Source

unexpected end-of-input generally means, you are missing an end somewhere. You need to write one more end in your code. Look at the block that you start at the end.

vertices.each do |vert|
   entities.add_cpoint(vert.position)
end

Put an end underneath here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download