Highlighted

Extendscript: Modifying MOGRT Text Using CEP Panel

Explorer ,
Jun 05, 2020

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!

TOPICS
Error or problem, How to, SDK

Views

339

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Extendscript: Modifying MOGRT Text Using CEP Panel

Explorer ,
Jun 05, 2020

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!

TOPICS
Error or problem, How to, SDK

Views

340

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jun 05, 2020 0
Adobe Employee ,
Jun 08, 2020

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. 


Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 08, 2020 0
Explorer ,
Jun 08, 2020

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 08, 2020 0
Adobe Employee ,
Jun 08, 2020

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)? 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 08, 2020 0
Explorer ,
Aug 07, 2020

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;
worked in version 14.0 and earlier when endTime was of time number (for seconds), but endTime must now be a time object for it to work in newer versions. 

A few other calls seemed to take different arguments and were causing the behavior I described above, but I can confirm now that the functionality I was looking for is working in Premiere 14.3. I'm assuming this is because I created my CEP panel using Old World Scripting but haven't modified everything for New World Scripting; is there a place I can refer to for all the changes I might want to make to my panel when moving from Old World to New World Scripting?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 07, 2020 0
Adobe Employee ,
Aug 07, 2020

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 07, 2020 0