# encoding: UTF-8
begin
  puts "###DZW-CAPTURE-WIDE-20260920"
  m = Sketchup.active_model
  cov = nil
  m.active_entities.each do |e|
    next unless e.is_a?(Sketchup::Group) || e.is_a?(Sketchup::ComponentInstance)
    cov = e if (e.respond_to?(:name) ? e.name.to_s : '') == '하부프레임커버'
  end
  vw = m.active_view
  cam0 = vw.camera
  dir = 'E:/도진팩토리/3D스캔및티칭시스템/_자동화/inbox'
  begin
    c = cov ? cov.bounds.center : m.bounds.center
    shots = [
      ['iso', Geom::Point3d.new(c.x - 3500.mm, c.y - 4500.mm, c.z + 2200.mm)],
      ['side', Geom::Point3d.new(c.x, c.y - 6000.mm, c.z + 300.mm)]
    ]
    shots.each do |tag, eye|
      vw.camera = Sketchup::Camera.new(eye, c, Geom::Vector3d.new(0, 0, 1))
      vw.zoom_extents
      f = "#{dir}/_wide_#{tag}.png"
      vw.write_image(f, 1600, 1000, true)
      puts "캡처 #{tag}=#{f} 존재=#{File.exist?(f)}"
    end
  rescue Exception => e2
    puts "캡처 실패 #{e2.class}: #{e2.message}"
  ensure
    vw.camera = cam0
  end
  puts "모델 수정 없음 / 저장 없음"
rescue Exception => e
  puts "EXC #{e.class}: #{e.message}"
end
nil
