Best Way to Make a Specific CompItem, the activeItem
Posted: March 13th, 2007, 9:43 pm
I have been banging my head against this issue because half the time things seem to work, and the other half is spent testing my chair's durability against a katana sword.
My understanding is that in order to 'do stuff' with an object's attribute (a JavaScript object property, as defined in Scripting Manual), the object must be called into focus/made to be the activeItem upon which the script references for code execution.
There are many instances in which a script may call upon objects in a project, that need to be referenced through difering criteria. For example:
1. Check to see if there is an activeItem in the project panel and test to make sure that item is a CompItem (has been successfully implemented)
2. Unselect the activeItem(s) in a project so that the focus can change to a new object requiring different parameters to become the activeItem, (has been successfully implemented)
3. Make active any type of item in the project panel, that was not already selected (50% successful , 50% chair left).
- this can be accomplished by referencing the item[index]. But what if you do not know / or cant force what that index # is?
- this can presumably be accomplished referencing the app.project.item.name? It makes sense that I should be able to do this
but it almost never works. And when it does, the next project I open, it seems to stop working. Here is a snippet:
I know I am doing many things wrong. Most importantly, I am concerned that I am misunderstanding the principals behind scripting. Guidance, instruction, thoughts etc., would be appreciated.
My understanding is that in order to 'do stuff' with an object's attribute (a JavaScript object property, as defined in Scripting Manual), the object must be called into focus/made to be the activeItem upon which the script references for code execution.
There are many instances in which a script may call upon objects in a project, that need to be referenced through difering criteria. For example:
1. Check to see if there is an activeItem in the project panel and test to make sure that item is a CompItem (has been successfully implemented)
2. Unselect the activeItem(s) in a project so that the focus can change to a new object requiring different parameters to become the activeItem, (has been successfully implemented)
3. Make active any type of item in the project panel, that was not already selected (50% successful , 50% chair left).
- this can be accomplished by referencing the item[index]. But what if you do not know / or cant force what that index # is?
- this can presumably be accomplished referencing the app.project.item.name? It makes sense that I should be able to do this
but it almost never works. And when it does, the next project I open, it seems to stop working. Here is a snippet:
Code: Select all
var selectedComp = new Array();
for (var i = 1; i <= app.project.items.length; i++)
{
if ((app.project.items[i] instanceof CompItem)&&(app.project.items[i].name == "RENDER"))
selectedComp[selectedComp.length] = app.project.items[i];
selectedComp.selected = true;
}