class WCO_ADDENDPOINTS
  def WCO_ADDENDPOINTS::start
    # get the active model
    model = Sketchup.active_model
    #get currently selected objects
    selection_set = model.selection
    vertices = []

    Sketchup.active_model.start_operation "Pointify edges"
    selection_set.each {|edge|
      if edge.typename == "Edge" then
        vertices = vertices + edge.vertices
      end
    }
    vertices.uniq!
    0.upto(vertices.length-1) do |i|
      Sketchup.active_model.active_entities.add_cpoint vertices[i]
    end
    Sketchup.active_model.commit_operation
  end #def
end #class

toolbar = UI::Toolbar.new "WCO-Toolbar"

cmd = UI::Command.new("Verbindungspunkte setzen...") {
  WCO_ADDENDPOINTS.start
}
cmd.small_icon = "WCO_ADDENDPOINTS/addendpoints_icon.png"
cmd.large_icon = "WCO_ADDENDPOINTS/addendpoints_icon.png"
cmd.tooltip = "Add Endpoints"
cmd.status_bar_text = "Add Endpoints"
cmd.menu_text = "Add Endpoints"
toolbar.add_item cmd
