Class to get information on the currently running macro More...
| string | filename() |
| bool | isAutostart() |
| string | trigger() |
macro is a static hub for the C++ macro that is running right now. There is no object to construct: call macro::filename, macro::isAutostart, and macro::trigger. filename is the full path of the file on disk. isAutostart is true when an event such as opening a layout started the script rather than the user choosing it from a menu. trigger names that event: layoutOpen, layoutStart, layoutNew, or schematicNew. A typical use is to install the current file as setup::autostartMacro when it was not already started by an event. This class exists only for LayoutEditor C++ macros; other scripting languages are not started by those events. It was introduced with release 20201021.
Example:
if (!macro::isAutostart() && (macro::filename() != "")) {
setup::autostartMacro = macro::filename();
if (!setup::autostartMacroTrigger.contains("layoutOpen"))
setup::autostartMacroTrigger.append("layoutOpen");
return 0;
}
if (macro::trigger() == "layoutOpen") {
// folder-level autostart after a design was opened
}
Returns: the complete filename, including its full path, of the macro calling this function.
Returns: true if this macro was started by an event such as layout open. Otherwise false.
Returns: the name of the event that started this macro. Supported events are layoutOpen, layoutStart, layoutNew, schematicNew.