# encoding: UTF-8
m = Sketchup.active_model
def r1(v); (v*25.4).round(1); end
g = m.entities.grep(Sketchup::Group).find{|x| x.name=="조립부원판_20260919"}
b = g.bounds
holes = 0
g.entities.grep(Sketchup::Face).each{|f| f.loops.each{|lp| holes += 1 unless lp.outer? }}
puts "조립부원판_20260919: solid=#{g.manifold?} hidden=#{g.hidden?}"
puts "  bbox (#{r1(b.min.x)},#{r1(b.min.y)},#{r1(b.min.z)})..(#{r1(b.max.x)},#{r1(b.max.y)},#{r1(b.max.z)})"
puts "  볼트구멍(내부루프/2면) = #{holes/2}개  faces=#{g.entities.grep(Sketchup::Face).length}  하위그룹=#{g.entities.grep(Sketchup::Group).length}"
puts "  체적=#{(g.volume*16387.064/1e6).round(2)}L 중량=#{(g.volume*16387.064/1e6*7.85).round(1)}kg"
# 정배율 복원체 확인
ci = m.entities.grep(Sketchup::ComponentInstance).find{|c| c.name.to_s =~ /SWD조립체_정배율/ || c.definition.name.to_s =~ /SWD조립체_정배율/}
puts "SWD조립체_정배율_20260919: #{ci ? "보존됨 #{r1(ci.bounds.min.x)},#{r1(ci.bounds.min.y)},#{r1(ci.bounds.min.z)}" : '없음'}"
g2 = m.entities.grep(Sketchup::Group).find{|x| x.definition.name=="그룹#2"}
puts "CEO 원본 그룹#2: 보존 bbox (#{r1(g2.bounds.min.x)},#{r1(g2.bounds.min.y)},#{r1(g2.bounds.min.z)})"
puts "내가 만든 잔여 그룹: #{m.entities.grep(Sketchup::Group).select{|x| x.name =~ /커버|채널|보강|오일탱크|마운트/}.map{|x| x.name}.inspect}"
m.selection.clear
m.selection.add(g)
m.active_view.zoom(g)
puts "SEL=#{m.selection.length} (#{m.selection.first.name}) MODIFIED=#{m.modified?} 최상위ents=#{m.entities.length}"
"FIN3"
