Page 1 of 1

Re-using a named solid/comp

Posted: December 9th, 2006, 11:11 pm
by slawes
I have written a short script to add a masked solid acting as a 2:35 reticule to selected footage items. First it creates comps for the footage items, and then adds a masked solid to each comp.
All works fine and dandy, but it does create as many solids as footage items. No biggy, but it would sure be nice to be able to re-use the initial solid I create in the proceeding comps, since it has exactly the same specs.
For the life of me I am sure there is a way, but can't find the correct function - the script guide leaves alot to be desired in user friendlyness.
Right now I am using the .layers.addsolid command, and have found the .byname command in the script guide, but have no idea on how to use it successfully - or whether it is indeed the right command I am looking for.

Many thanks,
Stephen Lawes.

Posted: December 10th, 2006, 1:00 am
by vidpat
In my VolumeLight.jsx script, I wrote a little function that probably could be tweaked to fit your purpose: addBlackSolid().

Essentially, this just looks for an existing solid that meets the specs I needed, and if it finds it, it adds it to the given composition. Otherwise, it creates the needed solid. It stores a global reference to the solid in the script, but this isn't really necessary, since it could do the search each time. (I also see that I didn't bother to have the function check the type of the parameter, so be careful with it as is.)

I hope this helps.

cool

Posted: December 11th, 2006, 12:28 pm
by slawes
Thanks Peter, that makes sense.
However for some reason - I'm just figuring this whole scripting thing out - I'm having difficulty with that command.
I striped out a temp script which highlights the problem -

var tempComp = app.project.items.addComp("temp",1920,1080,1,1,24);
var tempSolid = tempComp.layers.addSolid([0.0,0.0,0.0],"2:35 reticule",1920,1080,1,1);
var newSolid = tempComp.layers.add("2:35 reticule");

The third line just returns an error that it is not of the correct type.

What gives ?
Thanks.
-Stephen

Posted: December 11th, 2006, 12:39 pm
by vidpat
The paramter to add() should be a reference to the object, not the string of its name. So, for that third line, try:

var newSolid = tempComp.layers.add(tempSolid);

Posted: December 31st, 2006, 8:46 am
by slawes
Thanks Peter. I really need to take a scripting course of some kind.

-Stephen.