Page 1 of 1

Resizing Solids and Adjustment layers...

Posted: March 19th, 2010, 1:18 pm
by herbie
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...

Re: Resizing Solids and Adjustment layers...

Posted: March 19th, 2010, 6:04 pm
by Dan Ebberts
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

Re: Resizing Solids and Adjustment layers...

Posted: March 22nd, 2010, 4:49 pm
by herbie
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?

Re: Resizing Solids and Adjustment layers...

Posted: March 22nd, 2010, 5:27 pm
by Dan Ebberts
Try it with SolidSource instead of solidSource.

Dan

Re: Resizing Solids and Adjustment layers...

Posted: March 22nd, 2010, 5:42 pm
by herbie
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?

Re: Resizing Solids and Adjustment layers...

Posted: March 22nd, 2010, 6:20 pm
by Dan Ebberts
OK - I think I spotted something else.
Change this:

var curLayer = curComp.layer[j];

to this:

var curLayer = curComp.layer(j);


Dan

Re: Resizing Solids and Adjustment layers...

Posted: March 22nd, 2010, 6:56 pm
by herbie
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!

Re: Resizing Solids and Adjustment layers...

Posted: March 22nd, 2010, 7:01 pm
by Dan Ebberts
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

Re: Resizing Solids and Adjustment layers...

Posted: March 22nd, 2010, 7:19 pm
by herbie
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...

Re: Resizing Solids and Adjustment layers...

Posted: March 22nd, 2010, 7:46 pm
by Dan Ebberts
This should work:

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


Dan