19.12.2016 Views

Architectural_Design_with_SketchUp

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Architectural</strong> <strong>Design</strong> <strong>with</strong> <strong>SketchUp</strong><br />

max_val = 200<br />

# Get all attractor points<br />

sel.each { |e|<br />

if e.typename == ‘Group’<br />

attractors.push e.bounds.center<br />

end<br />

}<br />

# Iterate through objects and scale based on distance<br />

if attractors.length > 0<br />

# Do this for each group<br />

sel.each { |e|<br />

if e.typename == “ComponentInstance”<br />

# Get the center of the group<br />

center = e.bounds.center<br />

# Set the y-value to zero so that we<br />

# scale “outward”<br />

center.y=0<br />

# Calculate minimum distance between face and<br />

# all attractors<br />

dist = 1000000 # Start <strong>with</strong> a large number<br />

# Find the smallest distance<br />

attractors.each { |apoint|<br />

dist_calc = apoint.distance center<br />

dist = dist_calc if dist_calc < dist<br />

}<br />

# Calculate scale<br />

scale = (dist/max_val)**2<br />

t = Geom::Transformation.scaling (center, 1, scale, 1)<br />

e.transform! t<br />

}<br />

end<br />

end<br />

As you can see in the last few lines of code, this scaling transformation uses the syntax<br />

that allows for different scale factors in each dimension. Because the panels are oriented<br />

<strong>with</strong> the y direction (the components’ green axis) perpendicular to the wall, all other scale<br />

factors remain as 1.<br />

270

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!