Rename Cue from Preset
Resolve a specific cue, look up a preset by its pool address, and rename the cue to match the preset's name.
ts
import { is } from 'grandma3-toolkit';
function Main(): void {
// 1. Resolve the cue using MA3 query syntax. Sequence names with
// spaces must be wrapped in double quotes. GetObject returns
// `GenericObj | undefined`, so null-check first.
const cue = GetObject('Sequence "MySeq" Cue 2');
if (!cue || !is.Cue(cue)) {
Printf('Sequence "MySeq" Cue 2 not found.');
return;
}
// 2. Resolve the preset by pool address. "Preset 5.3" means
// pool index 5, entry 3 within that pool.
const preset = GetObject('Preset 5.3');
if (!preset || !is.Preset(preset)) {
Printf('Preset 5.3 not found.');
return;
}
// 3. Rename the cue to match the preset's name.
cue.name = preset.name;
Printf(`Renamed cue to "${preset.name}".`);
}
export = [Main];Notes
GetObject(query)returns the first object matching MA3's query syntax — the same string you'd type at the command line. Returnsundefinedif nothing matches, so always null-check before doing anything else.is.Cue/is.Presetcome fromgrandma3-toolkitand act as TypeScript type guards. The combinedif (!x || !is.Cue(x))first narrowsxtoGenericObj, then to the specific class — so inside the rest of the function.nameis properly typed.Preset 5.3uses MA3'sPool.Itemnotation. Adjust the address for your show.- Writing
cue.namemutates the object directly; MA3's command-line representation updates immediately.