Presentation is loading. Please wait.

Presentation is loading. Please wait.

SECTION 3 MACROS: OVERVIEW.

Similar presentations


Presentation on theme: "SECTION 3 MACROS: OVERVIEW."— Presentation transcript:

1 SECTION 3 MACROS: OVERVIEW

2

3 What Is in this section Macro Overview Macro Object Parameters
Ways to Create Macros Executing Macros Debugging Macros

4 MACROS: OVERVIEW Definition
A macro is an object that adds a command to the Adams/View language to execute a series of Adams/View commands. Adams/View treats a macro as it does all other Adams/View commands.

5 MACROS: OVERVIEW (CONT.)
Purpose Automate model building, simulating, and reviewing Examples: Generate a series of objects Generate a series of plots for a simulation Build an entire model (one for parts, one for joints, one for forces, and so on). Automate user preferences You can also write macros to automate how you work in Adams/View. For example, you can: Automatically turn icons on or off Specify a certain grid size Set whether or not to use the external Adams/Solver library, and so on. Icon settings (visibility, size, color) Grid settings (on/off, size, and so on) Solver preferences (use external/internal, save files, and so on)

6 MACROS: OVERVIEW (CONT.)
Types Parameterless Executes the Adams/View commands stored in the macro. With parameters You can add parameters to a macro that will be evaluated when the macro is executed. This makes the macro more generic.

7 MACRO OBJECT PARAMETERS
To create a macro, you must specify: Name (for database storage and reference). We recommend that you save your macros in a user-created library. If you save them in the .gui library, they will not be upward compatible. By default, macros are saved at the root level of the database. A command that will run the macro. The default is the macro name. The commands the macro will execute. What to do in case of a subsequent Undo.

8 WAYS TO CREATE MACROS Macro editor
Here, you enter the name of the macro and a unique command string that executes the macro. Command text area

9 WAYS TO CREATE MACROS (CONT.)
Record/Replay You can create a macro by recording a sequence of steps. Once you start the recording process, you perform the operations that you want to be included in the macro. Then, you stop the recording process and play it back. You can also save the macro you just recorded. Reading text from a file You can create a macro by using the Read command to read in an existing command file containing the commands to be executed. You can also assign a help file or text string to the macro that explains the macro’s use. The file you supply that contains the macro definition is a standard command file but it can also contain parameters embedded in the commands and can have special comments at the top.

10 WAYS TO CREATE MACROS (CONT.)
Example for reading text from a file macro read & file_name = "part_replicate_single_mac.cmd" & macro_name = .par_rep_single

11 EXECUTING MACROS When you create a macro, the command is added to Adams/View language. Command line Enter the command (with any applicable parameters) in the command line of the Command Window. Command line

12 EXECUTING MACROS (CONT.)
Command Navigator The Command Navigator displays a list of all Adams/View command keywords. When you select an object, a dialog box appears in which you enter parameters for executing the command. Selecting this command… Opens this dialog box

13 EXECUTING MACROS (CONT.)
Custom dialog boxes You can create a custom dialog box that upon execution executes a macro. Other macros If needed, a command within a macro can execute another macro.

14 DEBUGGING macros Using list information and temporary variables
Using the ADAMS Command Debugger Crawl-walk-run approach

15 DEBUGGING (CONT.) Using list information and temporary variables
You can debug a macro if you: Create it in pieces. Store the pieces in variables. Get list information on these variables. For more information on building function expression strings in a macro, see the Knowledge Base Article KB , available at: B Using the ADAMS Command Debugger Used for heavy development Unsupported and details undocumented

16 DEBUGGING (CONT.) Crawl-walk-run approach Crawl - Learn the commands
Use interface to facilitate. Execute by interface (GUI), Command Navigator, and so on. Review commands and parameters (log file and Command Window). Add to macro editor and test. Walk - Add parameters and qualifiers Declare parameters and simple qualifiers. Substitute parameters into commands. Test. Add looping constructs, if necessary. Use temporary variables. Run - Fine tune Add comment lines Remove dependencies (model object names, environment, and so on). Add error trapping (using IF condition). Add detailed qualifier, as needed.

17 Exercise Perform Workshop 3, “Macros Overview,” in your exercise workbook

18


Download ppt "SECTION 3 MACROS: OVERVIEW."

Similar presentations


Ads by Google