# encoding: UTF-8
m = Sketchup.active_model
v = m.active_view
a = m.entities.grep(Sketchup::Group).find{|g| g.name=='연결브라켓_L_A_20260919'}
b = m.entities.grep(Sketchup::Group).find{|g| g.name=='연결브라켓_L_B_20260919'}
puts "A=#{!a.nil?} B=#{!b.nil?} TOP=#{m.entities.count}"
# 간섭 체크(바운딩박스 교차)
[['A',a],['B',b]].each do |nm,g|
  hits = m.entities.grep(Sketchup::Group).select{|o| o!=g && !o.hidden? && o.bounds.intersect(g.bounds).valid? && (o.bounds.intersect(g.bounds).width.to_mm>0.01)}
  puts "#{nm} bbox 교차 그룹: #{hits.map{|o| o.name.to_s.empty? ? '(무명)' : o.name}.inspect}"
end
[[a,'shotA'],[b,'shotB']].each do |g,tag|
  bb=g.bounds; c=bb.center
  eye = Geom::Point3d.new(c.x - 350.mm, c.y - 500.mm, c.z + 250.mm)
  cam = Sketchup::Camera.new(eye, c, Z_AXIS); cam.perspective = true
  v.camera = cam
  out = "E:/도진팩토리/3D스캔및티칭시스템/_자동화/#{tag}_L브라켓_20260919.png"
  v.write_image(out, 1500, 1000, true)
  puts "#{tag}=#{File.exist?(out)}"
end
nil
