Resizing Solids and Adjustment layers...

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
herbie
Posts: 13
Joined: March 16th, 2010, 5:37 pm

So I've tried to resize the solid's width and height and it says its read-only... I don't want to scale the solid because it will retain the dimensions of the original... How do you script going into solid settings and changing the width and height that way?

app.project.item(1).layer(1).width = 1920; -->says it's read-only...
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

I think you have to change the width of the solid's source:

app.project.item(1).layer(1).source.width = 1920;


This, of course, means that any other solid layers that have the same source get changed as well.


Dan
herbie
Posts: 13
Joined: March 16th, 2010, 5:37 pm

oh thank you! that works... however, I ran into a bit of a new problem...

So I have part of a script that will change the width and height of the selected Compositions... also, I added another loop that, for each comp, will go through each layer and find the solids and change the width and height...
The problem is it won't find the solids.. it just stops.. not sure why either... here's the code I have so far.

{
app.beginUndoGroup("Test");
var everyItem = app.project.items;
for (var i = 1; i <= everyItem.length; i++)
{
item = everyItem;
if ((item instanceof CompItem) && item.selected)
{
var curComp = item;
curComp.width = curComp.width * 2;
curComp.height = curComp.height * 2;

for (var j = 1; j <= curComp.numLayers; j++)
{
var curLayer = curComp.layer[j];

if (curLayer.source.mainSource instanceof solidSource)
{
curLayer.source.width = curLayer.source.width * 2;
curLayer.source.height = curLayer.source.height * 2;
}
}
}
}
app.endUndoGroup();
}

Am I close?
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

Try it with SolidSource instead of solidSource.

Dan
herbie
Posts: 13
Joined: March 16th, 2010, 5:37 pm

Okay, so I tried that... and I ended up with 2 different errors...
the first one, it said "unusable code at line 17.. which is where my 'if' statement is...
The second one happened after I tried again and it just froze After Effects...

Is it really case sensitive too?
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

OK - I think I spotted something else.
Change this:

var curLayer = curComp.layer[j];

to this:

var curLayer = curComp.layer(j);


Dan
herbie
Posts: 13
Joined: March 16th, 2010, 5:37 pm

Awesome! Between changing the solidSource to SolidSource and changing the [] to (), both are now resized!

They didn't line up at first, but I guess I have to double the position as well...

Thanks for all your help!
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

If you have layers with no source (like text layers) you'll need to change your test to something like this:

if (curLayer.source != null && curLayer.source.mainSource instanceof SolidSource)

Dan
herbie
Posts: 13
Joined: March 16th, 2010, 5:37 pm

oh wow... I had no idea they didn't have a source... good to know..

So I have a really stupid question now... how can you move the position of the solid?

I've tried curLayer.position = [960, 540];
That doesn't seem to work.. even though their aren't any errors... also
curLayer.source.position = [960, 540];

However, these are not variables... how would I go about doubling the x and y in position?
Sorry, I'm new at this After Effects part of scripting...
Dan Ebberts
Posts: 320
Joined: June 26th, 2004, 10:01 am
Location: Folsom, CA
Contact:

This should work:

var oldVal = curLayer.property("Position").value;
curLayer.property("Position").setValue([oldVal[0]*2,oldVal[1]*2]);


Dan
Post Reply