Re-using a named solid/comp

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
slawes
Posts: 25
Joined: December 9th, 2006, 12:38 pm
Location: LA, California

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.
vidpat
Posts: 86
Joined: October 21st, 2004, 12:36 am
Location: Phoenix, AZ
Contact:

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.
slawes
Posts: 25
Joined: December 9th, 2006, 12:38 pm
Location: LA, California

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
vidpat
Posts: 86
Joined: October 21st, 2004, 12:36 am
Location: Phoenix, AZ
Contact:

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);
slawes
Posts: 25
Joined: December 9th, 2006, 12:38 pm
Location: LA, California

Thanks Peter. I really need to take a scripting course of some kind.

-Stephen.
Post Reply