Execution Rules
Consider the following rules about the execution of macros:
• In asynchronous mode, macros are executed as soon as they are loaded with ProMacroLoad().
• In synchronous mode, the mapkey or the macro strings are pushed onto a stack and are popped off and executed only when control returns to from the Creo TOOLKIT program. Due to the last in, first out nature of the stack, macros that cannot be passed entirely in one ProMacroLoad() call should have the strings loaded in reverse order of desired execution.
• To execute a macro from within Creo TOOLKIT, call the function ProMacroExecute(). The function runs the macro and returns the control to the Creo TOOLKIT application. It executes the macros previously loaded using the function ProMacroLoad(). The function works only in the synchronous mode.
• Do not call the function ProMacroExecute() during the following operations:
◦ Activating dialog boxes or setting the current model
◦ Erasing the current model
◦ Replaying a trail file
• Clicking the OK button on the dialog box to complete the command operation. In this case, the dialog box may be displayed momentarily without completing the command operation.
|
Note:
|
• You can execute only the dialog boxes with built-in exit confirmation as macros, by canceling the exit action.
• It is possible that a macro may not be executed because a command specified in the macro is currently inaccessible in the menus. The functional success of ProMacroExecute() depends on the priority of the executed command against the current context.
|
• If some of the commands ask for an input to be entered from the keyboard (such as a part name), the macro continues execution after you type the input and press ENTER. However, if you must select something with the mouse (such as selecting a sketching plane), the macro is interrupted and ignores the remaining commands in the string.
This allows the application to create object-independent macros for long sequences of repeating choices (as long as the user does not have to select any geometry).
A ProStringToWstring() call for defining the macro string must be followed by the following calls:
• ProMacroLoad(macro wstring) to load the macro strings or the mapkey
• ProMacroExecute() to execute the macro
Some sample macros in various scenarios are given below.