Have Script need GUI Window ...

What type of scripts do you need?

Moderator: byronnash

Post Reply
scribling
Posts: 143
Joined: May 1st, 2005, 1:52 pm

How do you turn an old script into a cool GUI window?
We use this script and it would be really cool if we could have it as a GUI window.

Code: Select all

//////////////////////////////////////// 
//"Update Project Name Text" script, version 1.6. 
//This script was created by Christopher R. Green on 5-8-2005 
//  (modified 5-15-2005) 
//  using Tex-Edit Plus and jEdit. 
//This script will look for all text layers named "projectname" and "version" (or whatever 
//  the variables below are set to) and set the source text of those layers. 

//If you have questions, you can make a post or 
//  send an email via creativecow.net (After Effects forum) 
//  or aenhancers.com (I am 'zold' there) 
//You are free to use this script however you please. 
//If you make changes to it, please tell me (CRG) about it. 

//put inside undo block: 
app.beginUndoGroup("Update Project Name Text"); 
var p=app.project; 
var projTLayersFound=[]; 

var projTextName = "projectname"; 
var slateVersName = "version"; 

//get project name: 
//this assumes a project name of the format <foo_v##_##.???> or <foo_v##_##.????> where ??? and ???? are 3 and 4 character file extensions 
//the first line here strips the extension, the 2nd line strips the extension and the first part of the base name before the underscore 
var projName = p.file.name.replace(/%20/g, "_").replace(/\.(.{3,4}$)/, ""); 
var versText = (  p.file.name.replace(/%20/g, "_").replace(/\.(.{3,4}$)/, "").replace(/(^.{1,}?)\_/, "")  ); 
var projTLayersFound = 0; 
var versTLayersFound = 0; 

//loop through comps and layers: 
for (i = 1; i <= app.project.numItems; ++i) { //for/next loop goes through all project items 
   var currentComp = p.item(i); 
    
   if (currentComp instanceof CompItem) { //test if current item is a composition 
    
      //if it is a comp item, look for the "projectname" text layer 
      //  and look for the "version" text layer 
      
      var theseLayers=currentComp.layers; 
        
      for (o = 1; o <= theseLayers.length; ++o) { //this loop goes through all layers 
        
         var currentLayer = theseLayers[o]; 
        
         //make sure it's a text layer, and that its name is correct 
         //(ignore if it's not a text layer or it's a text layer with wrong name) 
        
         if ( currentLayer.property("sourceText") != null) { 
          
            if (currentLayer.name == projTextName ) { 
               projTLayersFound = (projTLayersFound + 1); 
              //set its value: 
               currentLayer.sourceText.setValue(projName); 
            } else if (currentLayer.name == slateVersName ) { 
               versTLayersFound = (versTLayersFound + 1); 
              //set its value:        
               currentLayer.sourceText.setValue(versText); 
            } 
           } 
   }//inner for 
}//if compItem 
}//outer for 

//alert("\n" + "\"" + projTextName + "\" text layers found: " + projTLayersFound + "\n" + "\"" + slateVersName + "\" text layers found: " + versTLayersFound); 

app.endUndoGroup();
Thanks in advance.
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

Which part do you want in the GUI? It seems to be a pretty automated script.
scribling
Posts: 143
Joined: May 1st, 2005, 1:52 pm

We basically just need a single button. Although, two buttons would be great. One that would increment and save and the other that would update the slate.

Thanks
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

Just use Jeff Almasol's Launch Pad. It basically give you a palette to launch any script you want from a button you can even design yourself! Add one for the Increment and Save script and one for this other script. :D

http://www.adobe.com/cfusion/exchange/i ... id=1242019

-Lloyd
Post Reply