require 'sketchup.rb'

def designer

  mesh = Geom::PolygonMesh.new

  IO.foreach("c:/Temp/su.txt"){

    |line|

    data = line.split

    x1 = data[0].to_f
    y1 = data[1].to_f
    z1 = data[2].to_f

    x2 = data[5].to_f
    y2 = data[6].to_f
    z2 = data[7].to_f

    x3 = data[10].to_f
    y3 = data[11].to_f
    z3 = data[12].to_f

    point1 = Geom::Point3d.new x1, y1, z1
    point2 = Geom::Point3d.new x2, y2, z2
    point3 = Geom::Point3d.new x3, y3, z3

    index1 = mesh.add_point point1
    index2 = mesh.add_point point2
    index3 = mesh.add_point point3

    mesh.add_polygon index1, index2, index3
  }

  model = Sketchup.active_model
  entities = model.active_entities
  group = entities.add_group
  groupEntities = group.entities
  groupEntities.add_faces_from_mesh(mesh)

end

if(file_loaded("designer.rb"))
  menu = UI.menu("Plugins");
  menu.add_item("Archipelis Designer import") { designer }
end

file_loaded("designer.rb")







