Титульная страница
ISO 9000 ISO 14000
GMP Consulting
 
Mastering CorelDRAW 9

Previous Table of Contents Next


Chapter 33
Scripting Success

Featuring

Scripts: the evolution 809

Script basics 811

Advanced scripting 816

Choosing between a style, a script, and a scrap 818

Case study: Debbie does CorelSCRIPT 820

Are you fond of red text set in 100-point Futura, with a drop shadow offset of 20% black? How about adding perspective and custom fountain fills to objects? Whatever your specialty, repeating the same steps over and over for your favorite effects is not likely to rank as your favorite CorelDRAW activity. DRAW’s scripting tool enables you to record transactions and then play them back to quickly format text and objects. Using scripts is like plugging a very efficient tape recorder into your computer, and since DRAW 7, scripts have had a significant impact on how many advanced users go about their business.

Back in DRAW 6 we gave less than two pages to the scripting tool, and we suspected that very few users would use it. We were right: not too many DRAW users had the time or inclination to learn a programming language in order to record repetitive steps. But now everything is different, thanks to the little red Record button in the Script and Preset Manager. It’s just like the one on your VCR or cassette recorder—it listens, and then it plays back. As a result, the potential of the tool has increased manyfold.

Scripts: the Evolution

Before there were scripts, there were presets, an awkward way to store an effect for later use. Now that the scripting tool is so much more robust, presets are being phased out. In DRAW 9, as in 8 and 7, you cannot create a preset for a general effect, although there are other places on the interface where the word “preset” is used—like fountain fills, texture fills, and print styles. But to accommodate users who have created presets from previous versions and still want to use them, the Script and Preset Manager can play them back (hence its name). Our assumption is that the only users who would need to work with presets are those who already know how to create them; in fact, for simplicity, we will refer to the tool as the Script Manager instead of its more verbose name (except where we are indicating the name of the command as it appears on the interface).

DRAW 9 includes several premade scripts—in fact, you may find the very effect you are looking for prerecorded for you. Go to Tools Ø Corel SCRIPT Ø Script and Preset Manager to display the docker. The Scripts folder is shown in Figure 33.1, with each script represented by a thumbnail. On the page is a rectangle to which we applied the fillout script, which created an artistic outline for it.


FIGURE 33.1  To apply these scripts to an object, double-click the script, right-click and choose Apply, or press the triangular Play button.


NOTE In addition to the folder shown in Figure 33.1, ready-made scripts are also stored in the Scripts subdirectory directly below the main CorelDRAW directory. There you will find some generic scripts, including one that turns your CD-ROM drive into a music jukebox. We’re sure that DRAW users around the world have been waiting anxiously for that one...

Script Basics

While there is considerable depth to DRAW’s implementation of scripts, on the surface, things are simple: you record a script and then you play it back. If you remember those two things, you can’t go too far wrong.

Recording a Script

Imagine the following scenario: You have several drawings that need a particular effect applied to them. They each need a rectangle to be placed against a vertical guideline, to be skewed up by 30 degrees, and then to have a 45-degree black-to-white fountain fill applied to it. This is a perfect time to create a script, because you need to automate several actions at once. Styles can’t do it, templates can’t do it, and the Scrapbook can’t do it. Here are the steps to take:

1.  Before you begin, turn on Snap to Guidelines (that is the only part of this exercise that can’t be recorded in a script).
2.  Choose Tools Ø Corel SCRIPT Ø Script and Preset Manager to open the docker. Click on the red Record button. From this point, DRAW watches your every move, and stores all “recordable actions” as part of the script.
3.  Create a vertical guideline at the 4-inch mark on the ruler. (You can create it somewhere else, but remember its location.)
4.  Create a rectangle that snaps to the guideline.

Note two things about the previous graphic: the round Record button in the docker is grayed out, indicating that it has been pressed (that is your only visual cue), and we have backed out one level in the docker. We find it helpful to have a separate place to record personal scripts—away from the prefab ones—and one level up in the directory structure makes sense (so you can easily get to the others).

5.  Press F11 to reach the Fountain Fill dialog. Set a fountain fill (the default of black to white is fine) with an angle of 45 degrees. (The script doesn’t care how you issue commands—here, you could have pressed F11, or used the Fill flyout, or the Interactive Fill tool.)
6.  Switch to the Pick tool and click on the rectangle to get its rotation handles.
7.  Hold Ctrl while you drag the middle-left handle up. Release after two “snaps.”

8.  Press the black Stop button on the Script Manager to stop recording.
9.  In the Save Recording dialog, choose a location, supply a name, and optionally, a description, as shown on the facing page. DRAW will store the script and use the object you created as the thumbnail.

This beats the heck out of all previous methods for creating scripts or presets, as you’ll see in a moment. To finish the story, let’s play back your script, by following these steps:

10.  Get a new drawing by pressing Ctrl+N.
11.  Find your newly created script and play it back (double-click, right-click and Apply, or click the Play button).

In an instant, DRAW should create the vertical guideline and the skewed rectangle, just as you did when you created the script (only much faster, and with less effort on your part).


Previous Table of Contents Next
 
Rambler's Top100