Scott Mcgee
Forum Replies Created
-
Hi Aris,
Thank you for this. Thought I’d at least reply late on haha.
I wasn’t as experienced back in 2017 with scripting.
I was working for a central station providing graphics to all the individual stations. They had to create quick graphics. So i built templates that allowed them to do this. They were also gits who didn’t know how to use after and would massively destroy my projects and complain that they couldn’t use them (Not all. Just one or two). So I used to build plugins where it stored simple templates like this one for bar graphs that they used in a few of their shows. Again complaining that it only had 1-4 graphs and sometimes they would want 15, or 2. They were also lazy, so if I built 15 templates, with 1-15 bar graphs. Again they’d complain.
So I built a plugin so if they duplicated the Bar layer, it would resize and equally space itself.
But, the expressions if you moved them around or stuck in a text layer inbetween them. The expression would break.
So the script went through all the layers checking for the slider that animated them. Incase they renamed the layers, or did anything that I knew they would. It would find that and then change the layers name to Bar 1,2,3 etc.
I don’t work there any more, but looking at your expression would have done the trick hahaha.
-
Unless there’s a tidier way, I think I found something that I’ve altered that appears to work.
minDur = .5;
maxDur = 1;
t = tPrev = inPoint;
seedRandom(index,true);
while (t <= time){
tPrev = t;
t += random(minDur,maxDur);
}
s = random(100,300);
[s,s]
-
Scott Mcgee
October 11, 2021 at 4:31 pm in reply to: Using expression to loop layer and trim Work Area?Hey Sami,
Not too sure what you might be having trouble with but just incase.
If you’ve copied and pasted into Extendscript, make sure “” aren’t “”. I’ve noticed the code I’ve copied and pasted back then did that has done that. So they’ll need to be swapped. Same goes for ” and ‘’
Once these have been replaced then it should work no problem.
If not, can you specify what the error is coming back with, but it should be saying something on the lines of.
unable to execute script at line 1. syntax error
If it’s saying something like this, then it’s the “” and ”.
Hope that helps.
-
Scott Mcgee
September 28, 2020 at 8:00 am in reply to: Every X seconds, move in a random direcition.This will help you get started
segDur = 1;
minVal = [0.1*thisComp.width, 0.1*thisComp.height];
maxVal = [0.9*thisComp.width, 0.9*thisComp.height];
seed = Math.floor(time/segDur);
segStart = seed*segDur;
seedRandom(seed,true);
startVal = random(minVal,maxVal);
seedRandom(seed+1,true);
endVal = random(minVal,maxVal);
ease(time,segStart,segStart + segDur, startVal, endVal);
This was by Dan Ebberts from his website here https://motionscript.com/mastering-expressions/random-1.html
As for the pause in the middle. I don’t have time to write some up, but you should be able to add a delay between each movement.
Hope this steers you in the right direction.
-
Scott Mcgee
September 15, 2020 at 4:56 pm in reply to: Is there any script to resize comp adding pixels over original value?It’s because I copied and pasted and my “” changed to ““…And yes that does matter. Now if you copy and paste below. It will work.

var mySelectedItems = [];
for (var i = 1; i <= app.project.numItems; i++){
if (app.project.item(i).selected)
mySelectedItems[mySelectedItems.length] = app.project.item(i);
}
for (var j = 0; j < mySelectedItems.length; j++) {
var comp = app.project.selection[j];
var origCompSize = [comp.width,comp.height];
var newCompSize = [origCompSize[0] + 300, origCompSize[1] +100];
comp.width = newCompSize[0];
comp.height = newCompSize[1];
comp.layer(1).property(“Position”).setValue([comp.width/2,comp.height/2]);
}
-
Scott Mcgee
September 9, 2020 at 8:13 am in reply to: Is there any script to resize comp adding pixels over original value?As long are you are changing the anchor point when it’s placed into the comp in the first place.
This should work 🙂
var mySelectedItems = [];
for (var i = 1; i <= app.project.numItems; i++){
if (app.project.item(i).selected)
mySelectedItems[mySelectedItems.length] = app.project.item(i);
}
for (var j = 0; j < mySelectedItems.length; j++) {
var comp = app.project.selection[j];
var origCompSize = [comp.width,comp.height];
var newCompSize = [origCompSize[0] + 300, origCompSize[1] +100];
comp.width = newCompSize[0];
comp.height = newCompSize[1];
comp.layer(1).property(“Position”).setValue([comp.width/2,comp.height/2]);
}
-
Scott Mcgee
August 24, 2020 at 4:36 pm in reply to: Is there any script to resize comp adding pixels over original value?That was quicker than I thought it would be to write.
var mySelectedItems = [];
for (var i = 1; i <= app.project.numItems; i++){
if (app.project.item(i).selected)
mySelectedItems[mySelectedItems.length] = app.project.item(i);
}for (var j = 0; j < mySelectedItems.length; j++) {
var comp = app.project.selection[j];
var origCompSize = [comp.width,comp.height];
var newCompSize = [origCompSize[0] + 300, origCompSize[1] +100];
comp.width = newCompSize[0];
comp.height = newCompSize[1];
}Any comps you select in the project window will be increased by 300 width and 100 height.
-
Scott Mcgee
August 24, 2020 at 4:11 pm in reply to: Is there any script to resize comp adding pixels over original value?Simple answer is yes.
Not sure if you are wanting to change 100 in one click or as you are importing the files.
but I don’t know if there is a free or purchase script to do the job, but if you are comfortable with scripting. Essentially this is it
var comp = app.project.activeItem;
comp.width = 1920;
comp.height = 1080;You can adapt to take the original size
var comp = app.project.activeItem;
var origCompSize = [comp.width,comp.height];var newCompSize = [origCompSize[1] + 300, origCompSize[0]+100];
comp.width = newCompSize[0];
comp.height = newCompSize[1];That will change the size of the active comp open in AE, but if you stick that into a loop of selected comps (little more complex, not that much) in the project window that will resize all the comps based on their size and add 300px width and 100px height.
-
Personally I’d just include an update button and function that to update/refresh the menu. There’s plenty of bits about on this sort of thing if you want it to update. (attached some code below)
Depending on what you want this menu to do. I.e if you have a few scripts you want to combine, have you thought about tabbed panels to switch between them.
If it’s data you want to pull from the project and have it update in the script panel. Then back to the first solution of adding and update/refresh button.
If you are opening whilst AE is already open and opening another project. The script doesn’t know this as it doesn’t reverse communicate. You’d have to put in app.project.close() and app.open() into your script and trigger this, you’d need to include save if you wanted it to save. But then you’d still be using the above function of updating and/or refreshing the panel still.
{
function myScript(thisObj) {
function myScript_buildUI(thisObj) {
var myPanel = (thisObj instanceof Panel) ? thisObj : new Window ("palette", "Manheim", undefined, {resizable:true} );var mainGroup = myPanel.add("group");
var btn = mainGroup.add("button",undefined,"Update");btn.onClick = function () {
cleanUpGroup(grpContainer);
var btn1_1 = grpContainer.add("button", undefined, "1_1");
var btn1_2 = grpContainer.add("button", undefined, "1_2");
var btn1_3 = grpContainer.add("button", undefined, "1_3");
var btn1_4 = grpContainer.add("button", undefined, "1_4");
updatePanel(myPanel);
};var grpContainer = myPanel.add("group");
// Setup panel sizing and make panel resizable
myPanel.layout.layout(true);
myPanel.layout.resize();
myPanel.onResizing = myPanel.onResize = function () {this.layout.resize();}return myPanel;
}function cleanUpGroup(container) {
while (container.children[0]) {
container.remove(container.children[0]);
}
}function updatePanel(win) {
win.layout.layout(true);
}// Build script panel
var myScriptPal = myScript_buildUI(thisObj);if ((myScriptPal != null) && (myScriptPal instanceof Window)) {
myScriptPal.center();
myScriptPal.show();
}
}// Execute script
myScript(this);
}
This updates the panel and might be of help to you possibly.
-
Scott Mcgee
August 24, 2020 at 11:01 am in reply to: AE Scripting: JSX parsing JSON file already in ProjectI don’t think that is possible. Even using the expression function, AE has inbuilt support to parse it in the background. However I don’t know if that is done when importing. If you trying and access it in the project file like so
app.project.selection[0].file;
alert(file);
you get the filePath and if you try this like a json file
app.project.selection[0].file;
alert(file[0]);
you get undefined. So I assume that AE does something in the background that you just can’t do with extend script and extend script doesn’t have the ability to natively read Json.However if your json file is in the timeline you can access that data using extend script easily by accessing the properties. Tried to go backwards from there, but kept getting undefined. So unless anyone jumps in, unfortunately the script I wrote a few years back is the only way to still access json from the project window.
It just allows you to skip selecting a file from a folder or having the script remember the file pat. So there is some benefit.
I prefer using script to expressions, purely because it when it comes to exporting. It is so much faster. I know AE is getting better, but when you have hundreds of expressions. It slows down export time dramatically.