SU freezes when creating lines - ruby plugin

First of all. Generally in SketchUp, all geometric primitives (faces, edges, arcs, polygons) should be associated with “Layer0”. Only group and component instance containers should be associated with other layers. (ie, layers are not geometric containers in SketchUp. Only groups and component instances separate geometry.)

2.) Coding questions go in the forum’s Developers > Ruby API subcategory.
(Admins have reassigned to correct category.)

3.) Please wrap code correctly in forum … [How to] Post correctly formatted and colorized code on the forum?

This is know to occur when Ruby has a lot of work to do.
So use a model undo operation and set the 2nd argument true to disable the UI.

Poor example ... click to view. (See better example below.)
for c in 1…$edges_count
  this_edge = edges_array[c - 1]
  model.start_operation("Draw edges",true)
    entities_edges.add_edges(this_edge[0], this_edge[1])