Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Delete Comp From Project

Guest
May 18, 2011 May 18, 2011

Hey Guys,

I am trying to delete a comp from the project using its name.

I got it to work using its index....

app.project.item(3).remove();

but I am having trouble getting it to work using its name.

Suggestions?

Thanks in advance,

Tyler

TOPICS
Scripting
628
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , May 18, 2011 May 18, 2011

Unfortunately you can't access it directly by name. You have to loop through the project items until you find it, like this:

var myProject = app.project;
var myItem = null;

for (var i = 1; i <= myProject.numItems; i++){
    if (myProject.item(i) instanceof CompItem && myProject.item(i).name == "comp name"){
        myItem = myProject.item(i);
        break;
    }
}

Dan

Translate
Community Expert ,
May 18, 2011 May 18, 2011

Unfortunately you can't access it directly by name. You have to loop through the project items until you find it, like this:

var myProject = app.project;
var myItem = null;

for (var i = 1; i <= myProject.numItems; i++){
    if (myProject.item(i) instanceof CompItem && myProject.item(i).name == "comp name"){
        myItem = myProject.item(i);
        break;
    }
}

Dan

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 18, 2011 May 18, 2011
LATEST

Worked perfectly! Thanks again Dan!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines