Copy link to clipboard
Copied
So I have a newbie question on changing properties from within a selected MOGRT on a timeline in Premiere Pro.
I can provided both a test MOGRT and JSX file to better explain what I am trying to achieve (I tried attaching them, but got an unsupported file type error). I also copy/pasted the script below:
//testScript_01
var trackItems = app.project.activeSequence.videoTracks.numTracks; //number of tracks
for(i=0;i<trackItems;i++){ //for each track
var clipItems = app.project.activeSequence.videoTracks[i].clips.numItems; //number of clips in current track
for (c=0;c<clipItems;c++){ //for each clip within the current track
var selectedMOGRT = app.project.activeSequence.videoTracks[i].clips[c]; //currently targeted clip
//selectedMOGRT.setSelected(true);
if (selectedMOGRT.isSelected() == true){ //if targeted clip is a selected in timeline
if(selectedMOGRT.isMGT() == true){ //if selected clip is a MOGRT
var component = selectedMOGRT.getMGTComponent(); //get all MOGRT component properties
var c = 2; //USER VARIABLE for component to change
var v = 25; //USER VARIABLE for new value
var comp = component.properties[c].getValue();alert(comp); $.write(comp); //gets current value for component[c] and alerts/writes it
component.properties[c].setValue(v,1); //sets new value for component[c] as user variable
};
};
};
};
The MOGRT basically has 3 properties to change: 0 - Slider Controller, 1 - Color Fill, and 2 - Source Text (with cutom font and faux styles enabled).
I managed to access the component properties of the MOGRT but can't seem to figure out the correct values to input for 'Fill Color' or 'Source Text.'
For the slider (component.properties[0]), I get an expected value of 100 which I can easily change (to 25 in the example)
But I get a weird value for component.properties[1] color ('72337971214286848' I think it's decimal? Can't figure out how to convert to hex.) and a long array string for component.properties[2] text. When I try to change either one using the same method, I get an error. Even copy/pasting the same values given from .getValue() throws an error. Not sure what I am doing wrong?
Please help.
Finally found the solution for one of the issues! Stumbled upon it in the SDK guide. Anyways, found the solution for editing color parameters! If anyone else is having this same issue with color, hopefully this helps.
Just discovered I was using the wrong method. I've been using '.getValue()' and '.setValue()', But apparently for color parameters, there is a '.getColorValue()' and a '.setColorValue().'
Using '.getValue()' on a white color property returns: 280379743338240
But Using '.g
...Copy link to clipboard
Copied
Did you create this mogrt in Ae or Premiere?
Neil
Copy link to clipboard
Copied
I created the mogrt in AE and the script in ExtendScript Toolkit. I can provide both, but can't upload them to the inital post due to unsupported file format.
Copy link to clipboard
Copied
Changing mogrt properties via ExtendScript does not seem liek that much of a "newbie" question to me.
What is it that you are ultimately trying to do?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Have you looked at Mogrt creation in AfterEffects, which is designed to use scripting?
Neil
Copy link to clipboard
Copied
I have looked into MOGRT creation in After Effects (AE) and have made one for Premiere Pro.
I have also sucessfully been able to access the componet properties of that MOGRT in Premiere Pro (using scripting via ExtendScript) For the most part, I can change the values of most elements within the MOGRT/Essential Graphics Panel. But I'm currently struggling with figuring out what values to use for any 'Text Source' and 'Color' fields.
Essentially, all I want to know is what values to use in a script for 'Text Source' and 'Color' fields customization. These are the same parameters shown in the Essential Graphics Panel for a MOGRT that has been imported onto the timeline in Premiere Pro.
Example:
In Premiere Pro, assuming a MOGRT with a checkbox property as the first editable parameter is the first clip on track one, this script should set the value for that checkbox:
app.project.activeSequence.videoTracks[0].clips[0].getMGTComponent().properties[0].setValue(true,1);
Now using this same logic, say that MOGRT had a slider for the second parameter (which can be edited in the Essential Graphics Panel from within Premiere Pro), then this should set the value of that:
app.project.activeSequence.videoTracks[0].clips[0].getMGTComponent().properties[1].setValue(10,1);
Okay, now say that same MOGRT has a third parameter which is a color property that controls a fill effect that is applied to a layer within the MOGRT. My question is what value to use to correctly set the color:
app.project.activeSequence.videoTracks[0].clips[0].getMGTComponent().properties[2].setValue(??????????????,1);
Also, say that same MOGRT has a fourth parameter which is a text source property. How do I change all the values:
app.project.activeSequence.videoTracks[0].clips[0].getMGTComponent().properties[3].setValue(??????????????,1);
Not sure if this makes sense at all. But I just can't figure this out. Please help.
Copy link to clipboard
Copied
I would love to know a solution to this as well.
Is there any documentation or references anyone knows of for writing color or text property data in a script?
It would also be great very helpful to know what type of color code it is that Premiere returns: 72337971214286848
Austin Faure
Copy link to clipboard
Copied
Finally found the solution for one of the issues! Stumbled upon it in the SDK guide. Anyways, found the solution for editing color parameters! If anyone else is having this same issue with color, hopefully this helps.
Just discovered I was using the wrong method. I've been using '.getValue()' and '.setValue()', But apparently for color parameters, there is a '.getColorValue()' and a '.setColorValue().'
Using '.getValue()' on a white color property returns: 280379743338240
But Using '.getColorValue()' returns: 0,255,255,255
Thus using '.setValue()' on a color property gives weird results but '.setColorValue()' works like a charm.
Hope this helps.
Still looking for how to set text parameters, but will post once I find the solution as well.
Copy link to clipboard
Copied
Found what I was doing wrong with editing the text parameters and like editing color values, it was a simple solution.
As expected, I did not use the proper format for the '.setValue()' for a text property. But after some troubleshooting, I managed to get a value that works. I split the long string into multiple lines for better readability:
var newTextParam = ['{'
,'"fonteditinfo":{'
,'"capPropFontEdit":true,'
,'"capPropFontFauxStyleEdit":true,'
,'"capPropFontSizeEdit":false,'
,'"fontEditValue":"MyriadPro-Bold"'
,'"fontFSAllCapsValue":false,'
,'"fontFSBoldValue":false,'
,'"fontFSItalicValue":false,'
,'"fontFSSmallCapsValue":false,'
,'"fontSizeEditValue":200},'
,'"textEditValue":"New Text"'
,'}'].join("");
Now passing 'newTextParam' through the '.setValue()' method works and doesn't throw any errors! The full ExtendScript looks like this and should set the text parameters for a selected MOGRT on the timeline with a text source as it's first element:
var trackItems = app.project.activeSequence.videoTracks.numTracks;
for(i=0;i<trackItems;i++){
var clipItems = app.project.activeSequence.videoTracks[i].clips.numItems;
for (c=0;c<clipItems;c++){
var selectedMOGRT = app.project.activeSequence.videoTracks[i].clips[c];
if (selectedMOGRT.isSelected() == true){
if(selectedMOGRT.isMGT() == true){
var component = selectedMOGRT.getMGTComponent();
//SET NEW TEXT VALUES
var newTextParam = ['{'
,'"fonteditinfo":{'
,'"capPropFontEdit":true,'
,'"capPropFontFauxStyleEdit":true,'
,'"capPropFontSizeEdit":false,'
,'"fontEditValue":"MyriadPro-Bold"'
,'"fontFSAllCapsValue":false,'
,'"fontFSBoldValue":false,'
,'"fontFSItalicValue":false,'
,'"fontFSSmallCapsValue":false,'
,'"fontSizeEditValue":200},'
,'"textEditValue":"New Text"'
,'}'].join("");
//alert(newTextParam); //un-comment to alert variable.
//SETS NEW TEXT VALUES
component.properties[0].setValue(newTextParam,1);
};
};
};
};
Hope this solution helps someone who's having the same issue as I did.
Copy link to clipboard
Copied
I wanted to learn how to script in adobe primer pro , but I'm new to it.
I don't know how to edit texts inside the MOGRT type clips nor I know how to edit any other attribute within adobe primer pro MOGRT clips .
I tried your script but in the line "var component = selectedMOGRT.getMGTComponent(); " it apears that component here is undefined and when I'm excuting the line
component.properties[0].setValue(newTextParam,1);
I keep getting the error "....#21 undefined is not an object" .
I'm simply trying to change the source text inside the graphic/mogert clip but I keep getting errors.
Copy link to clipboard
Copied
so I thought there might be a mistake in my understanding to what is going on with the code so I created a sequance with one simple mogrt clip and I ran the code ,this is my code:
var project = app.project;
var sequence = project.activeSequence;
var videoTracks = sequence.videoTracks;
var thisTrack = videoTracks[0];
var clips = thisTrack.clips;
var thisClip = clips[0];
alert(thisClip.isMGT()); //this returns true!!!!!
//var seq = app.project.activeSequence;
//var time = seq.getPlayerPosition();
//var vidTrack = 1;
//var audTrack = 2;
var newMOGRT = thisClip;
newMOGRT.setSelected(true);
if (newMOGRT){
var components = newMOGRT.getMGTComponent(); // this doesn't give back an array??
for(var a=0;a<components.properties.numItems;a++){
$.writeln(components.properties[a].displayName);
}
}
sow what does the last for loop does is that it supposed to give back the name of properties that my mogrt clip have ..... but it gives an error when ever my script goes over it ...... any helps!!!!!!!!!
Copy link to clipboard
Copied
Hi @felixHonda_
I'm trying to implement the setValue for text but it's not working even using the code you provided.
Can you confirm if works on Premiere 15.0?
And can you inform from where or which extendscript docs you get the reference about mogrt?
Thanks in advance.
Copy link to clipboard
Copied
I'm not sure if that was the problem, but after getting the value for the text property at the mogrt, I notice the text is returning a different object, as below.
So, I just replaced the code, and worked fine. And since the value is a JSON object, I just declared it as an object and stringified it to pass as a parameter in the setValue:
//Current object
var textParamObj = {
capPropFontEdit: false,
capPropFontFauxStyleEdit: false,
capPropFontSizeEdit: false,
capPropTextRunCount: 1,
fontEditValue: [""],
fontFSAllCapsValue: [false],
fontFSBoldValue: [false],
fontFSItalicValue: [false],
fontFSSmallCapsValue: [false],
fontSizeEditValue: [0],
fontTextRunLength: [8],
textEditValue: "New Text"
};
var textParamString = JSON.stringify(textParamObj);
alert("textParamString " + textParamString); //un-comment to alert variable.
component.properties[0].setValue(textParamString, 1);