19.12.2016 Views

Architectural_Design_with_SketchUp

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6 Creating Geometry Using Ruby Scripting<br />

Whenever you work <strong>with</strong> components in Ruby, it is very important to have the component’s<br />

axes (the ones that you see when you edit or double-click the component) in the<br />

correct location. Copies will be placed using a component’s origin. Double-check their<br />

placement if your results don’t look as expected.<br />

TIP<br />

Figure 6.19: Selection for example<br />

# Use this to map a component onto the center of all selected faces<br />

mod = Sketchup.active_model # Open model<br />

ent = mod.entities # All entities in model<br />

sel = mod.selection # Current selection<br />

# Get the one component’s definition<br />

comp = nil<br />

sel.each { |e|<br />

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

comp = e.definition<br />

end<br />

}<br />

# Iterate through all ungrouped faces<br />

sel.each { |e|<br />

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

263

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

Saved successfully!

Ooh no, something went wrong!