Anda di halaman 1dari 28

Advanced Animation Techniques Part II

by Demetrios Halazonetis www.dhal.com

Using Macros for Animation


First create the object you wish to move. Then write a macro that moves the object. Add a custom action button on the slide. Then set the Action Settings of the button to trigger the macro.

Create the object


This is the easy part. The object can be a simple object or a group of objects. The next slide (Slide 4) has the object (mandible plus teeth, in a group). It also has other things on it, which will be explained later.

Rotate Animation Rotate Condyle

Rotate
RotateReset

Move ResetAll

Writing a macro (good luck)


NOTE: The following is a step-by-step step-byguide. However, the macros are already present in this file, so you should not follow these steps, unless you do it in a new PowerPoint presentation, which does not contain any macros.

Writing a macro (assuming no macros are already present)


Open the Visual Basic Editor: Tools>Macro>Visual Basic Editor In the Project box, select the VBProject and then select Insert>Module from the menu. The code window opens. If not, doubledoubleclick on the newly created module (Module1).

Writing a macro
Position the mouse cursor in the code area (the large window on the right) and select Insert>Procedure. Type SimpleRotate and make sure Sub and Public are selected. Click OK. In the code box, complete the procedure so it looks like the following: (next slide)

A simple procedure:
Public Sub SimpleRotate() SimpleRotate() Dim aSlide As Slide, aShape As Shape Set aSlide = ActivePresentation.Slides(4) Set aShape = aSlide.Shapes(1) aSlide.Shapes(1) aShape.Rotation = aShape.Rotation + 3 End Sub

Writing a macro
This procedure rotates the first shape (object) on Slide #4 by 3 degrees. To see it in action we need to attach it to an action object. (next slide)

Create an action button


Slide 4 has an action button Rotate. This was created by selecting: Slide Show > Action Buttons > Custom Then drag the mouse on the slide to create the button.

Create an action button


As soon as the button is created, the Action Settings dialog box opens. Select the Run Macro option and pick the SimpleRotate macro from the list box. The text on the button was entered after rightright-clicking the button and selecting Add Text from the pop-up menu. pop-

Now test it!


Go to slide #4. Click the Slide Show icon on the lower left of your screen. Use your mouse to click the Rotate button. The mandible and teeth should rotate each time the button is pressed.

Problems
How do we translate? How do we return the mandible to the original position?

More difficult problems


Rotation is around the center of the mandible. How do we rotate around the condyle? If we have more shapes on the slide, how do we specify (in the macro) which shape will move?

Some info to solve the problems


Slides have a coordinate system from 0,0 at the upper left corner, to 720,540 at the lower right. These coordinates hold for On-screen Show On(File>Page Setup). Macros permanently alter the placement of objects. Therefore, we require a macro to return the object to the original position. Else, use the Undo command (Edit>Undo) immediately after running the macro.

More help
An example of an undo macro for the SimpleRotate macro can be found in this file. It is the SimpleRotateReset macro. The main command is this: aShape.Rotation = 0 The RotateReset button on Slide #4 activates this macro. So after using the Rotate button, click the RotateReset button to return the mandible to the original position.

Translating objects
An example of a macro for translating objects is the SimpleMoveRightDown. Use the Move button on Slide #4 to activate it. The SimpleResetAll macro resets the mandible to its original position.

Animating movement
You can create continuous animation by repeating movements many times. The SimpleRotateAnimation demonstrates this. The main code is this: For n = 1 To 10 aShape.Rotation = aShape.Rotation + 3 DoEvents Next

Animating movement
We see that the heart of the code is the same as the SimpleRotate macro. It is just repeated 10 times. The DoEvents command allows PowerPoint to redraw the slide after each rotation, so that a continuous motion is perceived.

Specifying the slide in the macro


Slides in PowerPoint are held in a list. To specify e.g. slide #4, use a command such as this : Set aSlide = ActivePresentation.Slides(4) If you know the name of the slide you can also use this syntax: Set aSlide = ActivePresentation.Slides(Mouth)

Specifying the object in the macro


Objects in PowerPoint are held in a Shapes list. To specify the desired object (e.g. shape #1 in slide: aSlide) use a command such as this: Set aShape = aSlide.Shapes(1) If you know the name of the object you can also use this syntax: Set aShape = aSlide.Shapes(tooth)

Rotating around any point


To rotate an object around any point, use the RotateAround macro that is included in this file. You should include it in your own macros like this: RotateAround aSlide.Shapes(1), 3, 190, 140 (see the RotateCondyle macro and try the Rotate Condyle button on Slide #4. Remember to use the ResetAll button to return the mandible to the original position)

Helper file
PowerPoint does not have an easy way to rename objects or slides, or to figure out the coordinates of objects on a slide. You can use the ShowShapes.ppt file to help you do this. Open the file in PowerPoint and then run the ShowSlideObjects macro (with your .ppt file open at the same time). A dialog box will open, which shows all shapes on the current slide. You can rename the slide or the shapes on it. You can also see their Top, Left and Rotation properties so that you can write macros easier.

Example 1: Eruption and ankylosis

Reset

Click the teeth on the left, then the teeth on the right. Click Reset to return them to the initial position.

Example 2: Opening and closing

Open Close

Example 3: Torque

Click on the buttons in turn:


Torque wire Insert wire Torque is expressed Reset

Example 4: Activate T loop

Activate

Reset

Note: the template curves could be drawn with No Line, and would be invisible.

Good luck!
If you need help:
www.dhal.com

Anda mungkin juga menyukai