|
||||||||||||||||||||||||||||||
|
AutoCAD Tips & TutorialsRecord macros with the Action RecorderIn AutoCAD 2009, you can record macros for later use. This is a long-requested time saver. You can include requests for user input and messages to make the macro work interactively. When you save a macro, it has an ACTM filename extension. You'll find it in your Support\Actions folder of your AutoCAD installation. You can share ACTM files with others. Start by thinking about the conditions that you'll need when you run the macro. Will you be in model space or paper space? The macro doesn't keep track of all of the current settings. If a certain setting is necessary, use the system variable or the SETVAR command while recording the macro to make sure that you have the setup you'll need at playback time. Action Recorder macros have some limitations:
You may find other limitations. You'll find the Action Recorder on the Tools tab, in the Action Recorder panel. You can also choose Menu Browser (the A button)> Tools> Action Recorder.
Here's an example of how you would create a macro to change all objects to the default 0.25mm lineweight. You might get drawings from a company that adds lineweights to objects. Moreover, their default might be different. So this macro sets the default to 0.25, turns on the display of lineweights, and then uses the CHPROP command to change the lineweight of selected objects to the default. At the end, the macro turns off lineweight display.
Figuring out which commands to use often involves some research. For example, I knew that I could turn the lineweight display off and on using the button on the status bar, but I couldn't do that in the macro, since I didn't know which way the display would be when I played back the macro. If I wanted to turn the display on, and it was already on, clicking the button would turn it off! So I needed to find the system variable involved, which was LWDEFAULT. Then, it was easy to turn it on and off as needed. When you've figured out the steps that you want to take, and tried them out a couple of times in different situations, you're ready to record. Choose Tools tab> Action Recorder panel> Record. Your cursor now has a red dot, to show you that you're recording.
Go through the steps that you practiced. When you're done. click the Stop button that has replaced the Record button. You now have the opportunity to name and save the macro, as well as choose a few options.
Here is the command line that I created as I recorded:
Because I specified all at the Select objects: prompt, the macro will always select all objects. I tested that by adding more objects with a non-default lineweight; they were also changed. Here's what the macro looks like in the Action Recorder drop-down window:
I might want to be able to select individual objects. Letting the user select objects makes the macro interactive, and it's a very helpful feature. To do this, I reorganized the macro and used the SELECT command before the CHPROP command. While recording, I simply picked any objects. For the CHPROP command, I then used the p (Previous) option at the Select objects: prompt. When I was done, the macro looked like this:
Then I right-clicked the Select Objects item, and chose Request User Input, as shown below:
When I ran the macro, I got a dialog box asking if I wanted to provide user input. By accepting that option, I was able to either select objects, or enter all. If you have a useful macro that you recorded, I'd like to hear about it. Contact me, and attach the ACTM file. If I can successfully use it and it might be useful for others, I'll publish it (giving credit to you, of course).
|
|
|
|||||||||||||||||||||||||||
Home | AutoCAD | PowerPoint | E-Store
| About | Links | Contact | Site Map
|
||||||||||||||||||||||||||||||