Chapter 6
Creating Geometry Using Ruby Scripting
In this chapter, we will create scripted geometry in SketchUp. Often called computational geometry, this is an exciting current topic that allows you to produce 3D shapes and arrangements that are impossible (or at least hard) to create by hand. Scripting in SketchUp also allows you to automatize repetitive tasks or facilitate data exchange with text files.
Key Topics:
- What is computational geometry?
- Using Ruby Scripts in SketchUp
- Working with multiline editors
- Introduction to Ruby
- Overview of SketchUp’s API
- Creating scripted geometry
- Transforming geometry
- Modifying geometry based on attractors
Why Computational Geometry?
Even to the most seasoned SketchUp user, some tasks are challenging to complete by hand, using only the tools SketchUp provides. A good example is the creation of copies of a component where all the copies need to be placed at locations that vary not only linearly (e.g., “place a copy every 16 inches”) but also in intervals that are determined by a formula (e.g., where the y coordinate is determined by the square of x—which, of course, results in the shape of a parabola; see Figure 6-1).
Another example is a curved building whose window-shading devices need to be designed such that the degree to which they shade or open is determined by how far they deviate from the southern direction. (See Figure 6-2.)
Such tasks can sometimes be accomplished using one of the available plugins. However, those plugins are usually ...