Demo entry 6659052

the_exquisite_tower_fin

   

Submitted by anonymous on Nov 08, 2017 at 23:29
Language: Ruby. Code size: 2.2 kB.

mod = Sketchup.active_model
ent = mod.entities
grp = ent.add_group

depth = 1
width = 1
height = 1

pts = []
pts[0] = [0, 0, 0]
pts[1] = [width, 0, 0]
pts[2] = [width, depth, 0]
pts[3] = [0, depth, 0]

face = grp.entities.add_face pts
face.pushpull -height
box_00 = grp.to_component

for i in 1..64

copy = Geom::Transformation.new [0, 0, 0]
box_00.transform! copy
box_00.make_unique

for j in 1..64

box_01 = box_00.copy
#4th randomization!
copy = Geom::Transformation.new [0, 0, j * 0.8]
box_01.transform! copy

mat_01 = mod.materials.add 
mat_01.color = 242, 138, 46
box_01.material = mat_01

#2nd randomization!
pt0 = [rand(4..5), rand(-5..-4), 0]
vec = mod.axes.zaxis
#1st randomization!
ang = (j ** 2) * (180 / rand(16..32))

rot = Geom::Transformation.rotation pt0, vec, ang
box_01.transform! rot

pt1 = [0, 0, j]
#3rd randomization!
scl_x = rand(0.8..1.2)
scl_y = rand(0.8..1.2)
scl_z = rand(0.8..1.2)

scl = Geom::Transformation.scaling pt1, scl_x, scl_y, scl_z 
box_01.transform! scl

if i < 10 and j < 10

att = {
  :filename => "the_exquisite_tower_fin_0" + i.to_s + "_0" + j.to_s + ".png",
  :width => 1200,
  :height => 2000,
  :antialias => false,
  :compression => 1,
  :transparent => true
}
  
mod.active_view.write_image att

elsif i >= 10 and j < 10

att = {
  :filename => "the_exquisite_tower_fin_" + i.to_s + "_0" + j.to_s + ".png",
  :width => 1200,
  :height => 2000,
  :antialias => false,
  :compression => 1,
  :transparent => true
}

mod.active_view.write_image att

elsif i < 10 and j >= 10

att = {
  :filename => "the_exquisite_tower_fin_0" + i.to_s + "_" + j.to_s + ".png",
  :width => 1200,
  :height => 2000,
  :antialias => false,
  :compression => 1,
  :transparent => true
}

mod.active_view.write_image att

else

att = {
  :filename => "the_exquisite_tower_fin_" + i.to_s + "_" + j.to_s + ".png",
  :width => 1200,
  :height => 2000,
  :antialias => false,
  :compression => 1,
  :transparent => true
}

mod.active_view.write_image att

end

mat_01.color = 150, 149, 142

end

end

box_00.erase!
box_01.erase!

This snippet took 0.02 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).