# Smart Attic Model House V2 (80x80x60 cm, Flat Roof 30 deg, 6 Sensors) # Run in SketchUp: Window > Ruby Console -> load 'smart_attic_v2_sketchup.rb' module SmartAtticV2 def self.mm(v); v.to_f / 25.4; end def self.pt(x,y,z); Geom::Point3d.new(mm(x),mm(y),mm(z)); end def self.box(e,x,y,z,dx,dy,dz,m) g=e.add_group; f=g.entities.add_face(pt(x,y,z),pt(x+dx,y,z),pt(x+dx,y+dy,z),pt(x,y+dy,z)) if f; f.reverse! if f.normal.z<0; f.pushpull(mm(dz)); end g.material=m; g end def self.build model=Sketchup.active_model; model.start_operation('Smart Attic V2',true); e=model.active_entities m_w=model.materials.add('Smartboard'); m_w.color=[225,222,215] m_r=model.materials.add('FlatRoof'); m_r.color=[170,180,192] m_c=model.materials.add('Chimney'); m_c.color=[30,34,40] m_p=model.materials.add('Solar30W'); m_p.color=[20,48,105] w=800.0; d=800.0; h=600.0; ang=30.0*Math::PI/180.0; rh=(w/2.0)*Math.tan(ang) [0.0, 1440.0].each_with_index do |x0, idx| box(e,x0,0,60,w,d,h,m_w) if idx==1 box(e,x0+340,340,660+rh,120,120,500,m_c) box(e,x0+290,290,660+rh+590,220,220,15,m_c) box(e,x0+80,130,660+rh+40,450,540,22,m_p) end end model.commit_operation; model.active_view.zoom_extents end end SmartAtticV2.build