Copy link to clipboard
Copied
Hi, I'm trying to edit a Text field in a Motion Graphics Template using code in my CEP panel, but am running into issues. This is my code:
var components = newMOGRT.getMGTComponent();
components.properties.getParamForDisplayName("Text").setValue(customText);
This is doing exactly what I want in Premiere versions 13.1.5 and 14.0 (setting the text in the MOGRT to the value of the string variable customText). However, in Premiere 14.1 and 14.2, this doesn't change the text at all.
After reading this thread and this other one, I tried getting and setting the JSON object from the text field instead. So I changed the above code to this:
var components = newMOGRT.getMGTComponent();
var textObj = JSON.parse(components.properties.getParamForDisplayName("Text").getValue());
var theText = textObj.textEditValue;
textObj.textEditValue = "testing";
components.properties.getParamForDisplayName("Text").setValue(JSON.stringify(textObj), true);
This updates the MOGRT's text to "testing" in the Essential Graphics panel, but not in the Program Monitor. Instead no text shows up at all when I'm looking at the MOGRT. I'm able to get and set all sorts of other values like checkboxes and color controls in this MOGRT, but only text isn't working. It seemed to be working for users on those other threads so I'm at a loss. Is there something I'm missing?
My OS is macOS Catalina. Thanks!
var seq = app.project.activeSequence;
if (seq){
var result=seq.importMGTFromLibrary("Library Name",
"mogrt name",
timeInSeconds,
targetVideoTrackIndex,
targetAudioTrackIndex);
}
Copy link to clipboard
Copied
Hello Adrian,
I've confirmed that PProPanel's "Import .mogrt" button works correctly, in 12.x and 14.x.
In what application was the .mogrt with which you're testing, created?
Also, I notice you're using a "JSON" object. Relying on the JSON object available at the PPro global level is risky; it's only present/usable when the CC Libraries panel is open. Instead, we recommend building something like Douglas Crockford's JSON2.js into your panel.
In what version of PPro did you see that 'failure to update' issue? I ask because we fixed an issue like that, in 14.2.
Copy link to clipboard
Copied
Thanks for your response!
Sorry if it was unclear, but I'm not having trouble importing the MOGRT. I'm using ExtendScript to import a MOGRT using mainSequence.importMGTFromLibrary() (no trouble there) and then trying to edit the source Text field of that MOGRT. Editing the source Text using ExtendScript works fine in Premiere 13.x and 14.0, but not in newer builds of Premiere.
I've been successfully using JSON objects in my ExtendScript using the json2.js you linked. To check whether that was the issue, I also tried setting the Text value to this string instead:
var newText = '{"capPropFontEdit":false,"capPropFontFauxStyleEdit":false,"capPropFontSizeEdit":false,"capPropTextRunCount":1,"fontEditValue":["LabGrotesque-Bold"],"fontFSAllCapsValue":[false],"fontFSBoldValue":[false],"fontFSItalicValue":[false],"fontFSSmallCapsValue":[false],"fontSizeEditValue":[100],"fontTextRunLength":[21],"textEditValue":"This is my custom text."}'
This modifies the MOGRT in the Esssential Graphics panel, but the change doesn't reflect in the Program Monitor. That's the same behavior I see when working with the JSON object.
I remember reading in Premiere's list of known issues after version 14.0 that ExtendScript was having issues modifying MOGRT control values. Since that bug no longer appears here, I was hoping it was fixed.
To be clear, when I modify the source Text value in Premiere 13.1.5 or 14.0, I simply use the following:
components.properties.getParamForDisplayName("Text").setValue("This is my new custom text.", true);
and the Text field changes to "This is my new custom text." in both the Essential Graphics window and Program Monitor. In those versions of Premiere, using getValue() on the Text field returns only the string in that parameter's field from the Essential Graphics window. But in Premiere 14.1 and 14.2, a longer string in the form of a JSON (similar to the newText variable in the code block above) is returned instead. That's the reason I started trying to work with the JSON object in the first place. Using getValue("This is my new custom text.") on that Text field no longer makes any changes to the MOGRT, even though that works in earlier versions of Premiere.
The MOGRT was created in After Effects version 16.1.3. I also tried MOGRTs made in newer versions of AE, with the same results.
Copy link to clipboard
Copied
Getting and setting JSON blobs, which seems to work based on those threads, was never intended behavior.
> This updates the MOGRT's text to "testing" in the Essential Graphics panel, but not in the Program Monitor.
In what version(s) are you seeing that behavior? I ask because that's the bug we fixed at least one instance of, in 14.2.
As a starting point, could you try a fresh build of the PProPanel sample, and see whether it successfully imports and modifies the .mogrt it contains (see the extension's /payloads directory)?
Copy link to clipboard
Copied
Thanks for the help! I got it to work after trying the PProPanel sample and cross-checking my code. Turns out a few other calls I was making before trying to set the text were failing in newer versions of Premiere but were working before. In particular,
newMOGRT.end = endTime;
Copy link to clipboard
Copied
There isn't and good reference, because the intent was for you to not need to change anything, to move from Old World to New World. 🙂
However, one unavoidable change was that implicit type conversion to string no longer takes place; that's caused some confusion, as passing params that weren't strings used to work; New World is more strict / less accomodating.
Copy link to clipboard
Copied
Wow, that sounds amazing. I'm working on doing something similar - do you mind sharing the code you wrote to import the MOGRT from library, edit text, and add to timeline? Thanks!
Copy link to clipboard
Copied
var seq = app.project.activeSequence;
if (seq){
var result=seq.importMGTFromLibrary("Library Name",
"mogrt name",
timeInSeconds,
targetVideoTrackIndex,
targetAudioTrackIndex);
}