| |
| Architect's Walkthrough |
| © 2010, Martin Rinehart |
| |
OK, you've created the most beautiful house since Falling Water. Now you want to show it to the world with an animated walkthrough. That requires knowing a little SketchTalk in Motion. The bad news is that SketchTalk scripts are really Ruby plugin programs. The good news is that this short document is all you need. I'll explain everything you need to know before the second page is done. Then we get to scripting an actual walkthrough. You'll forget that you are writing Ruby programs.
Let's keep this simple. You could open and close doors with SketchTalk in Motion, but that's an advanced use. Let's just carry a camera as we walk into the house, turn it around as we move and zoom in and out. Hollywood director stuff, but no actors. (Actors are temperamental. Cameras are not.)
ce (camera eye) command, this way:
ce Geom::Point3d.new( 120, 120, 60 )
Fortunately, you can use the much simpler, [r,g,b] array notation, this way:
ce [120,120,60]
That places the eye at the position you specify. It does not change the target or field of view.
OK, on to vectors. "Vector" is a 3D geometry term for which you can substitute the word "direction." Suppose you want to move 10 feet away from the origin, parallel to the red axis. You could move the eye with the cem command, this way:
cem Geom::Vector3d.new( 120, 0, 0 )
Again, you can use [r,g,b] notation to do that more easily:
cem [120,0,0]
All of the SketchTalk in Motion camera commands have an optional "m" third letter that means "move" by a vector from the current location (or move by a number of degrees from the current value, for field of view).
cem [120,0,0], 5, 10
go
ce, cf and ct. These set the absolute point in space or number of degrees in the field of view. To specify a change from the current position or value, you append an "m" (as in "move"): cem, cfm or ctm. Each is followed by a value. An [r,g,b] array for eye or target, or a number of degrees (such as 35), for field of view. If the value is followed by start and stop seconds, it is animated. (The movement is divided into small parts. For example, a five second move at 24 frames per second, our animation speed, is 120 small moves.)
OK, now you know it all. Time to put it to use.
My house has proved invaluable for testing this scripting and, before that for testing my VisMap plugin. I'm quite fond of it, so please don't make fun. You should use your own house or other building and create your own walkthrough of, I'm sure, something much better designed than mine.
After making a plan, we start adding commands in the Ruby Console Pro. You have installed the Ruby Console Pro plus SketchTalk in Motion bundle haven't you? If you have, skip the next section.
|
Download Ruby Console Pro and SketchTalk in Motion |
You extract the bundle into your SketchUp Plugins folder. To find your Plugins folder, in SketchUp click Window/Ruby Console. In the Ruby Console, type what you see here in the white input bar:
Your Plugins folder is the one in the second line of the output window. (Ruby is case sensitive: "SketchUp" won't work. It has to be "Sketchup.")
Extract the zip into Plugins and then restart SketchUp. You should now have a "Ruby Console Pro" choice in your Window menu.
You could use a calculator, or you could enter 18' the way you see here. How did I know that it was 18'?
You click "Exec" to check your work:
Saving, often, is a good habit.
The file name you save as becomes your working temp file name.
Your output window confirms your work:
Or, if you make a mistake, it complains:
If you're like me, you enter your animation command, click "Exec" and wonder why nothing happens. Eventually, you remember that you have to give a go command to start the animations. Your animation command is registered with the "conductor." Prior to go, the conductor simply maintains a list of the animations he'll need to execute. Your first command is on his list.
So you add go and realize that cem as specified only moves your camera a little bit. You change that to ce and you try again. This time you find that 20 feet is too close for comfort. This one works:
Note that non-animated commands are all executed prior to go. They are not registered with the conductor. It is a good practice to use the "m" form for all commands registered with the conductor. Sometimes, such as when animation starts, this is a bit extra trouble but it will pay off in the long run. Let's use cem, camera eye move, here:
You specify where you want to be and subtract where you were, in each dimension. From here on, this gets simpler.
Note that I've added comments. From the "#" character on, the computer ignores whatever is there. It's your chance to annotate your script so that you can understand it later.
Now, this worked well until I got to the door. Then the camera flipped out. What's the problem? Simple, the target's green value is zero. (That's the front door.) It should have been set past the far wall. Simple to fix:
I've used the exact same seconds for the zoom that were used for walking into the living room. You could experiment with continuing the zoom for a second or two more. How did I know that another 35 degrees was right? I didn't. 20 wasn't enough. 40 was a bit much. Ergo, 35. What works for your walkthrough is probably something different. Try it.
If you were sharp-eyed, you noticed that my finished turn is not quite my planned turn. It's four turns, five seconds each with a second pause between them. There's a lot of "try it, change it, try it again" involved in our movie making.
Last, being a long-time geek, I added a comment at the top and bottom. Even if you're an architect having nothing to do with geek, this is still a good idea. The top comment identifies the script file and explains what it does. By being there, the bottom tells you that you've got the whole script. This is the final script:
Happy scripting!
F1, when the Ruby Console Pro has focus, gets you SketchTalk help if you forget. Do a File/New and try the sample "col" command.