Script to create a template layer & then add a layer? Possible?

Hello, I am just starting to learn javascript and would like to know if it's possible to do the following:
Open multiple .tiff or .jpg files into illustrator
On each file's layer 1, template = yes (it's a check box) and click OK
Add new layer 2, click OK
Save file
Close file
I tried creating an action to do this, but it does not work. I am doing some illustrator and photoshop work which has quite a lot of repetitive tasks & I know a script would be a huge timesaver.  This is just one of several scripts that I'd like to learn how to write.  Thanks very much for reading this post and for your help.  Best, Nancy

That's odd. According to the JS Object Model Viewer, you can change about everything in the standard Layer Option dialog using a script (print, preview, locked, visible, and even "dimPlacedImages") but not ... "template".

Similar Messages

  • How do I create a signature,and then add it to an e ailed document?

    How can I create a signature and then use it to sign a document in e mail?

    Not sure I understand the question correctly.
    Open Mail and click on Preferences under the Mail menu. Click on the Signatures icon in the toolbar. You can set up your signatures there.
    But if you are talking about adding a written signature, then you cannot do that within Mail. You would need to scan in an image of your written signature then manually add it to a signature you create in mail as a graphic image. That seems to work.

  • How can I create a template of a Data Flow Task in SSDT?

    The majority of the Data Flow Tasks that I build have the same five elements in them (OLE DB Source, Conditional Split, Derived Column, Data Conversion, and OLE DB Destination).  I'd love to have a template of a Data Flow Task which already contains
    these elements.  Is that possible for me to create, and how do I do it?
    I'm currently on SSDT 11.1, with Visual Studio Pro 2012.

    Hi Tim_Dorenkamp,
    If I understand correctly, you want to create a custom task, then add it as template of a Data Flow Task in SSIS Toolbox. So that you can use it in every packages.
    Just as Samir suggested, we can developing a Custom Task that create a class that inherits from the Task base class, apply the DtsTaskAttribute attribute to your new class, and override the important methods and properties of the base class, including the
    Execute method. The sample of create a custom task is for your reference:
    http://microsoft-ssis.blogspot.com/2013/06/create-your-own-custom-task.html
    Besides, as to your requirement, we can simply create a template package that including this Data Flow Task, then use this template to create new packages. If we want to use the Data Flow Task in an existing package, we can add a new package with the template,
    then copy the Data Flow Task from the new package and paste it to the existing package. For more details about create a template package in SSIS, please refer to the following thread:
    https://social.technet.microsoft.com/Forums/en-US/b0747467-daff-4fc8-9f81-20d68b38e5ee/change-default-for-package-protection-level?forum=sqlintegratio
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • While creating master item, can I add a check to copy from template

    Hi,
    While creating master items, can I add a check on copy template on the item to ensure item is created using some template?
    This will ensure many attributes gets proper value. If template is not copied, in later phases user faces problem with few attributes not being set.

    Regarding the final PDF you produce with the Print button; when the user hits the Print button the usual printer dialogue box is launched and s/he can select which pages he wants to print and the number of copies. I think this is what you said this is what your customer wants.
    Note: when you add the Print button, within the Acrobat Forms facility, you then go to Button Properties dialogue box and select  Actions, select the trigger (i.e. On Mouse Down); Add an Execute a menu Item, click on Add and select File > Print from the drop-down list. A bit complicated to explain here, but easier enough if you have a play around with it. Acrobat Forms are a wonderful facility – well worth exploring the many things you can do with them. Especially if you set up your document first in InDesign!
    Derek

  • I built an ad using layers saved it and then converted it to a jpeg. Now when I go into elements 11 to do anything else it will not allow to copy and paste to create a new layer. What am I missing?

    I built an ad using layers saved it and then converted it to a jpeg. Now when I go into elements 11 to do anything else it will not allow to copy and paste to create a new layer. What am I missing?

    You know that you lost the layers when you saved it as a jpeg, right? But you're saying you can't add layers to the jpeg now when it's open in the editor? Go to Image>mode and be sure it's RGB, for starters. Are all the commands in the Layer menu grayed out?

  • Powershell script to Scan Active Directory Attributes for Country and Department ,Then add to Sales Group then add to Distribution list based on Region

    Hey Scripting Guys,
    I have been in and out of Powershell last few years, not that great at it tbh !!! I'm looking for advice on how I can as in Title, Create a Powershell script to Scan Active Directory Attributes for Country and Department ,Then add to Group then add to Distribution
    list based on Region/Country
    I was thinking along the lines of get-aduser -LDAPFilter "(department=SALES France) and adding a where clause for country.
    Any help would be great.
    Dec

    So I have tried a few variations but get errors on both 
    get-aduser -LDAPFilter "(&(department=SALES)(c=us))" | Add-ADPrincipalGroupMembership -MemberOf "testgroup"
    get-aduser -LDAPFilter "(&(department=SALES)(c=fr))" | Add-ADGroupMember -identity "testgroup"
    Add-ADPrincipalGroupMembership : Object reference not set to an instance of an
    object.
    At line:1 char:86
    + get-aduser -LDAPFilter "(&(department=SALES)(c=fr))" | Add-ADPrincipalGroupMe
    mbership <<<< -MemberOf "testgroup"
    + CategoryInfo : NotSpecified: (:) [Add-ADPrincipalGroupMembershi
    p], NullReferenceException
    + FullyQualifiedErrorId : Object reference not set to an instance of an ob
    ject.,Microsoft.ActiveDirectory.Management.Commands.AddADPrincipalGroupMem
    bership

  • HELP! I've created a template for event badges and have been instructed by the client to insert the (200 ) names and relevant companies into it...Is there a script that can do this in illustrator? Should I be using Indesign?

    An events client I'm working for have asked me to create a template for badges. Rather than ask the printers to insert the names and companies of the individuals present at the event though, they want me to create all of the pdf files for (200+) people!
    I have an excel sheet of the people that will be present. My question is: is there a way to automate this? to define editable areas in a template and run some sort of batch processing script?
    Thanks!

    This would be a perfect job for Data Merge in InDesign. You can place your AI design into InDesign (minus the text fields), and then easily create a merge.

  • Can I create a template and that will allow me to add a region when i use i

    Is it possible to create a template that will allow me to add a region when i use the template on my pages? I have a region that allows the user to create content in the region, but now i would like to have another region next to it.
    thanks
    Angie

    You cannot add regions on a page that uses a portal template.

  • Trying to create user template and login script

    I'm trying to setup a machine at work that's got an Admin account and a Student account.
    I want the student account to have limited privileges and to reset the desktop, dock etc. (user template) upon login.
    I've got a document here that was created by a former employee that states the following:
    Create a user template: (do this from the admin account)
    *Sudo ditto /Users/Student /Student/Library/User\ Template/Student.lproj*
    Upon entering this into terminal I was getting a message saying the real path was wrong, and now nothing happens when I enter the above.
    Ok, so in: "system/Library/User Template" there is a folder called Student.lproj
    Within Student.lproj there are no files.
    Should Student.lproj even exist there with no contents for this to work? When Terminal creates a template, does it copy this information into Student.lproj or does it create a new folder for the template?
    The account is hanging for quite a while on Login and logout now as well.
    Once I create this template for the Student account, I need to create a login script that will restore the template upon login of the Student account.
    please help

    It's /System/Library/... not /Student/Library
    Also, if you want it to reset at log out, just have them log in as Guest.
    See this article: http://www.michaelsmac.com/modules.php?file=article&name=News&sid=394

  • I have a custom template.  When I edit it and try to save it asks me to name it and then I end up with an additional custom template.  How do I edit the template and save the changes without creating another template?

    I have a custom template.  When I edit it and try to save it asks me to name it and then I end up with an additional custom template.  How do I edit the template and save the changes without creating another template?

    Hi Atrec,
    If you don't need your old custom template, save your changes with the same template name. It will tell you that this template exists and will ask you Replace? Say yes (if you do want to replace the old with the new!)
    To delete unwanted templates, go to Finder > Menu > Go and press the option key. Your Library will show in the Go Menu. Navigate to Library > Application Support > iWork > Numbers > Templates > My Templates.
    Delete any unwanted template by dragging it to the Trash or click on it then command-delete.
    Having gone to all that trouble to find My Templates folder, right click (or control click) on it and Make Alias. Drag the Alias to any convenient place for a quick way to get back to that folder.
    Regards,
    Ian.

  • I want to create a 6X9 book template and then copy my 81/2 x 11 copy into it.

    I want to create a 6X9 book template and then copy my 81/2 x 11 copy into it. Thanks

    select the book in the source pane on the left and duplicate it (command-D) and then click on the themes button and select the new size/style/theme  --  closely inspect the book to be sure it is still correct (text may reflow due to size changes as may photo arrangement) - preview (
    Before ordering your book preview it using this method - http://support.apple.com/kb/HT1040 - and save the resulting PDF for reference - the delivered book will match it. ) and order if it is what you want
    LN

  • Sharing script to create slideshow

    Thanks for David Torno I have been able to hack together a basic slideshow script. There's still a lot more that could be done with it, but I wanted to share it so that others may be able to benefit.
    Essentially, it asks for a folder location where your photos are stored, reads them in, creates a comp for each photo, resizing them and creating a border around them, adds all of the photo comps to a master comp, then sequences them, adds in some fades and slightly random placement.
    Like I said, fairly basic. But quite the learning experience.
    Yes, there are templates available for slideshows, but none that I found that I could just add photos to and say "Display these with a border and random placement on the screen, fading in and out." All the ones I found required replacing placeholders, or some sort of manual changes to each photo. And they were generally limited to 10 to 30 images. This script, theoretically, should be able to handle hundreds of images easily.
    Next steps are to add movement to the photos (sliding across the screen as they fade in and out) and add a music track from a file (or files) selected during photo import.
    Enjoy!
    And thanks again to David Torno, plus anyone else who's script examples I may have borrowed ideas from.
    Dion
        createSlidehow v 1.0
        Developer: Dion Vansevenant
        Based on David Torno's "fileToCompToQ"
        This script creates a basic slideshow from a folder of images
         function createSlideshow(){
              try{
                   /*     DECLARE VARIABLES     */
                   var localFolder, renderToFolder, outputModuleName, jpgAEFolderName, compAEFolderName, newJPGParentFolder, myImportedFiles, newCompParentFolder, newCompParentFolder, grabFiles, grabFilesLength, extAry, compFrameRate;
                   /*     BEGIN VARIABLES TO CUSTOMIZE     */
                   jpgAEFolderName = "Photos";          //Folder name for imported files
                   compAEFolderName = "Photo_Comps";     //Folder name for resulting comps
                   extAry = new Array("jpg", "jpeg");               //Array of Strings. These are the file extension types you wish to import.
                   compFrameRate = 29.97;                                   //Frame rate for the newly created comps. Must be a float or integer value.
                   compDuration = 5;                                        //The duration of time, in seconds, that the new comps will be.
                    //masterComp Variables
                    var compWidth = 1920;  
                    var compHeight = 1080;  
                    var compPAR = 1;  
                    var compDur = 10;
                    var compFPS = 29.97;
                    //Create Master Comp
                    var masterComp = app.project.items.addComp("MASTER", compWidth , compHeight, compPAR, compDur, compFPS);
                    /*     END VARIABLES TO CUSTOMIZE     */
                   /*     START PROCESS     */
                    localFolder = Folder.selectDialog("Please select folder containing your JPG files.");                
                    // localFolder = new Folder("~/Desktop/Photos/");
                    if(localFolder != null && localFolder.exists == true){
                        app.beginUndoGroup("fileToCompToQ");
                             grabFiles = localFolder.getFiles();     //Retrieves all enclosed files
                             grabFilesLength = grabFiles.length;
                             //Process files
                             app.project.items.addFolder(jpgAEFolderName);     //Creates folder
                             newJPGParentFolder = findItem(jpgAEFolderName);     //Saves it for later use
                             extensionFilterAndImporter(grabFiles, grabFilesLength, extAry, newJPGParentFolder); //Imports files and puts them in a folder
                             myImportedFiles = storeFileObjsIntoArray(newJPGParentFolder);
                             //Process comps
                             app.project.items.addFolder(compAEFolderName);
                             newCompParentFolder = findItem(compAEFolderName);                                                 
                             createCompsAddToQ(newCompParentFolder, myImportedFiles, compFrameRate, compDuration);
                            addCompsToMaster(app.project);
                            mySequenceToLayer(compObj);
                            writeLn("All done");     //Adds this text to the Info Panel as a way to see when the script is done working.
                        app.endUndoGroup();
                   /*     END PROCESS     */
                   ///     FUNCTIONS     ///
                    // Add fades in and out to comps
                    function addFadeToComps(layerObj){
                        try{
                           // alert("Oops, module addFadeToComps is not ready yet");   
                           //alert("Entering addFadeToComps...");
                           var overLap = 1;
                           //alert("Working on layer "+layerObj.name+" with startTime of "+layerObj.startTime+" and outPoint of "+layerObj.outPoint);
                           layerObj.opacity.setValueAtTime(layerObj.inPoint, 0);                                                           
                           layerObj.opacity.setValueAtTime((layerObj.inPoint + overLap), 100);
                           layerObj.opacity.setValueAtTime((layerObj.outPoint - overLap), 100);
                           layerObj.opacity.setValueAtTime(layerObj.outPoint, 0);                                                           
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
                    } // end function addFadeToComps
                    // Add fades using Expressions
                    function addExpFadeToComps(layerObj){
                        try{
                            var myLayer = layerObj;
                            var myLayerOpacityProperty = myLayer.property("ADBE Transform Group").property("ADBE Opacity");                       
                            //Frames that fade will take place over
                            var fade = "30";                        
                            //encoded expression string with "fade" variable inserted                       
                            var myExpress = "fadeTime%20=%20" + fade + ";%0DopacityMin%20=%200;%0DopacityMax%20=%20100;%0DlayerDuration%20=%20outPoint%20-%20inP oint;layerDiff%20=%20outPoint-(layerDuration/2);%0DsingleFrame%20=%20thisComp.frameDuratio n;%0DanimateIn%20=%20linear(time,%20inPoint,%20(inPoint%20+%20framesToTime(fadeTime)),%20o pacityMin,%20opacityMax);%0DanimateOut%20=%20linear(time,%20(outPoint%20-%20framesToTime(f adeTime+1)),%20(outPoint-singleFrame),%20opacityMax,%20opacityMin);%0Dif(time%20%3C%20(lay erDiff) )%7B%0D%09animateIn;%0D%7Delse%7B%0D%09animateOut;%0D%7D";
                            //Applies expression
                            myLayerOpacityProperty.expression = decodeURI(myExpress);
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
                    } // end function addExpFadeToComps
                    // Add items to comp in reverse order to preserve numbering
                    function addCompsToMaster(projObj){
                        try{                   
                            for (var i = projObj.numItems; i != 0; i--){                                              
                                if (app.project.item(i) instanceof CompItem){ // <-- adds comps to the comp, but also tries to add MASTER, not good
                                    if (app.project.item(i).name != "MASTER"){ // <-- ok, filter out MASTER
                                        masterComp.layers.add(app.project.item(i),compDuration);
                                        compObj = app.project.item(1);
                                        layerObj = app.project.item(1).layer(1);
                                        layerObj.property("ADBE Transform Group").property("ADBE Opacity").setValue(0);
                                        addExpFadeToComps(layerObj);                                   
                                        imageSizeToCompSize(compObj, layerObj);
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}                
                     } // end function adCompsToMaster
                    // adds a white solid to create a border
                    function  addBorderToComps(compObj){
                        try{
                            var myBorder = compObj;
    //                        myBorder.layers.addSolid([1.0,1.0,0], "Frame", 50, 50, 1);
                            myBorder.layers.addSolid([1.0,1.0,1.0], compObj.name+"_Frame", compObj.width, compObj.height, 1);
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}                
                    } // end function addBorderToComps
                    // Loop through MASTER comp and manually do "Sequence Layers" to stagger start times.
                    // Also try to randomize placement of images on-screen
                    function mySequenceToLayer(compObj){
                        try{
                        // get number of items in MASTER comp
                            var numItems = compObj.numLayers;                   
                            for(i=2; i<=numItems;i++){
                                app.project.item(1).layer(i).startTime = app.project.item(1).layer(i-1).outPoint-2;
                                maxZ = compHeight-100;
                                minZ = 600;
                                maxX = compWidth-100;
                                minX = 600;
                                x = Math.random(minX,maxX)*100;
                                y = Math.random(minY,maxY)*100;
                                var myProperty = app.project.item(1).layer(i).position;
                                // If the result is even, add x,y change, otherwise subtract it
                                myEvenOdd = i%2;
                                if (myEvenOdd == 0){
                                    var newX = myProperty.value[0] + x;
                                    var newY = myProperty.value[1] + y;
                                }else{
                                    var newX = myProperty.value[0] - x;
                                    var newY = myProperty.value[1] - y;
                                myProperty.setValue([newX,newY,0]);
                            app.project.item(1).duration = Math.round(app.project.item(1).layer(numItems).outPoint);
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
                    } // end function mySequenceToLayer
                    /*     findItem() function
                            Arguments::
                                itemName: Name of the After Effects folder to find. Must be a String.
                    function findItem(itemName){
                        try{
                             var allItems = app.project.numItems;
                             for(var i=1; i<=allItems; i++){
                                  curItem = app.project.item(i);
                                  if(curItem instanceof FolderItem && curItem.name == itemName){
                                       return curItem;
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
                    } // end function findItem
                   /*     extensionFilterAndImporter() function
                        Arguments::
                             grabFiles:     Array of file objects
                             grabFilesLength:     Value must be an integer
                             extAry:     Array of Strings
                             newParentFolder:     String
                   function extensionFilterAndImporter(grabFiles, grabFilesLength, extAry, newParentFolder){
                        try{
                             var fileName, extPrep, ext, extAryLength, importOpt, newFile;
                             extAryLength = extAry.length;
                             for(var i=0; i<grabFilesLength; i++){
                                  fileName = grabFiles[i].displayName
                                  extPrep = fileName.split(".");
                                  ext = extPrep[extPrep.length-1].toLowerCase();
                                  for(var e=0; e<extAryLength; e++){
                                       if(ext == extAry[e]){
                                            writeLn(fileName);
                                            importOpt = new ImportOptions(grabFiles[i]);
                                            newFile = app.project.importFile(importOpt);     //Imports file into project
                                            moveItemToFolder(newFile, newParentFolder);     //Moves file into parent folder
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
                   } // end function extensionFilterAndImporter
                   /*     moveItemToFolder() function
                        Arguments::
                             projectItem:     Must be an AVItem
                             parentFolder:     Must be a FolderItem
                   function moveItemToFolder(projectItem, parentFolder){
                        try{
                             projectItem.parentFolder = parentFolder;
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
                   } // end function moveItemToFolder
                   /*     storeFileObjsIntoArray() function
                        Arguments::
                             sourceFolder:     Must be a FolderItem
                   function storeFileObjsIntoArray(sourceFolder){
                        try{
                             var itemAry, itemsInFolder, itemsInFolderLength;
                             itemAry = new Array();
                             itemsInFolder = sourceFolder.items;
                             itemsInFolderLength = itemsInFolder.length;
                             for(var i=1; i<=itemsInFolderLength; i++){
                                  itemAry[itemAry.length] = itemsInFolder[i];
                             return itemAry;
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
                   } // end function storeFileObjsIntoArray
                   /*     createCompsAddToQ() function
                        Arguments::
                             myImportedFiles:     Array of File objects
                             fps:                         Must be a float or integer value.
                   function createCompsAddToQ(compAEFolderName, myImportedFiles, fps, duration){
                        try{
                             var myImportedFilesLength, curFile, extFind, fileNameOnly, newComp;
                             myImportedFilesLength = myImportedFiles.length;
                             for(var c=0; c<myImportedFilesLength; c++){
                                  curFile = myImportedFiles[c];
                                  extFind = curFile.name.toString().lastIndexOf(".");
                                  fileNameOnly = curFile.name.substring(extFind, 0);     //Removes file extension
                                  newComp = app.project.items.addComp(fileNameOnly+"_Comp", curFile.width, curFile.height, 1, duration, fps);     //Creates new comp
                                  addBorderToComps(newComp);
                                  newComp.layers.add(curFile);     //Adds file to comp
                                  imageSizeToBorderSize (newComp, 5);                             
                                  moveItemToFolder(newComp, compAEFolderName);     //Moves new comp to folder
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
                   } // end function createCompsAddToQ
                    // resize layer to comp
                    function imageSizeToCompSize(compObj, layerObj){
                        try{
                            var curLayerBoundry, curLayerScale, newLayerScale, myNewLayerScale;
                            curLayerBoundry = layerObj.sourceRectAtTime(0,false);
                            curLayerScaleObj = layerObj.property("ADBE Transform Group").property("ADBE Scale");
                            curLayerScaleVal = curLayerScaleObj.value;
                            newLayerScale = curLayerScaleVal*Math.min(compObj.width/curLayerBoundry.width, compObj.height/curLayerBoundry.height);
                            myNewLayerScale = newLayerScale*.75;
                            curLayerScaleObj.setValue(myNewLayerScale);
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
                    } // end function imageSizeToCompSize
                    // resize image to less than frame
                   function imageSizeToBorderSize(compObj, frameOffset){
                       try{                       
                            var curLayerBoundry, curLayerScale, newLayerScale, myNewLayerScale;
                            layerPhotoObj = compObj.layer(1);
                            layerFrameObj = compObj.layer(2);
                            curLayerBoundry = layerPhotoObj.sourceRectAtTime(0,false);
                            curLayerScaleObj = layerPhotoObj.property("ADBE Transform Group").property("ADBE Scale");                       
                            curLayerScaleVal = curLayerScaleObj.value;                       
                            if (frameOffset != 0){
                                newScale = 100-frameOffset;
                                layerPhotoObj.scale.setValue([newScale,newScale,100]);
                            }else{
                                layerPhotoObj.scale.setValue([95,95,100]);
                       }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
                   } // end function imageSizeToBorderSize
               }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
           } // end function fileToCompToQ
         createSlideshow(this);
    } // end script

    DECLARE @Query VARCHAR(MAX)=''
    DECLARE @DbName VARCHAR(400) = '<DBNAME>'
    DECLARE @DbFilePath VARCHAR(400) = '<Valid DataFilePath>'
    DECLARE @DBLogFilePath VARCHAR(400)='<Valid LogFile Path>'
    SET @Query = @Query + 'CREATE DATABASE '+@DbName +' ON PRIMARY '
    SET @Query = @Query + '( NAME = '''+@DbName +''', FILENAME = '''+@DbFilePath+@DbName +'.mdf'' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) '
    SET @Query = @Query + ' LOG ON '
    SET @Query = @Query + '( NAME = '''+@DbName +'_log'', FILENAME = '''+@DblogFilePath+@DbName +'_log.ldf'' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)'
    print @query
    exec(@query)
    --Prashanth

  • A Script to Find and Replace Layer Names

    Are there any scripts to find and replace layer names?
    There is an excellent script available for Photoshop which allows you to not only replace words in layer names, but also insert words as Prefixes, Suffixes and Sequential Numbers.
    The illustrator version of this script only allows sequential numbering: It doesn't offer find and replacing of words.
    Ideally, it would be great if there was something that could do multiple find and replaces in one go:
    (e.g.
    You have layers like this Car, Dog, Bat
    You enter: car(Option1), dog(Option2), Bat(Option3)
    Your layers then become: Option1, Option2, Option3).

    big_smile, that's a very good start! Step 1 of Learning How To Script is indeed, adjusting an existing simple script to make it do more complicated things. (And usually then "break something", which is also a required part of the process.)
    You are correct in your observation this is repetitive stuff. For one or two different items that wouldn't be a problem, but in longer lists you soon get lost.
    The usual way of working with find-change lists is to build an array:
    var layernames = [
    [ 'FHairBowlBoy *Hair', 'Hairboy1' ],
    [ 'FHairCurlyafroBoy *Hair', 'Hairboy2' ],
    [ 'FHairSpikyBoy *Hair', 'Hairboy3' ],
    The general idea is to loop over all names, check if the current layer name is "layernames[i][0]" (the left column) and if so, rename it to "layernames[i][1]" (the right column). If you know how to write a loop in Javascript, then you can implement this right away.
    However ..
    A more advanced way to do this doesn't even need loop to over all layernames -- instead you can immediately "get" the correct name per layer! It's magic! Almost!
    The trick is to use a Javascript object instead of an array. Javascript objects are nothing special; Illustrator's 'layers' is an array of objects, and each object "layer" has a property "name", whose value you can read and set. What I do here is create a new object, where the "name" part is the original layer name and its value is the new layer name. All you need to check for per each layer is if there is a property 'object.originalLayerName', and if so, assign its value to that layer name.
    This looks a bit like the array above, except that (1) you use {..} instead of [..] to create an object, and (2) you add "name:value" pairs instead of "value" only (actually, the 'name' of a value in an array is simply its number).
    So this is what it looks like:
    // JavaScript Document
    var doc = app.activeDocument;
    // name indexed object
    var layernames = {
    'FHairBowlBoy *Hair':'Hairboy1',
    'FHairCurlyafroBoy *Hair':'Hairboy2',
    'FHairSpikyBoy *Hair':'Hairboy3'
    // loop through all layers
    for (var i = 0; i < doc.layers.length; i++)
    //Set up Variable to access layer name
    var currentLayer = app.activeDocument.layers[i];
    if (layernames[currentLayer.name])
      currentLayer.name = layernames[currentLayer.name];
    Enjoy!

  • Customized scripts within the Deployment Template environment

    Hello,
    In the endeca documentation I see that "The sample scripts provided with the Deployment Template control the Endeca operational tasks through the EAC. You can use these scripts, or create custom scripts based on them. The scripts typically run such processes as routine baseline and partial updates. You can also add specific scripts that run before the Dgraph is stopped or after it is started."
    I would like to call a .bat before the DGraph is stopped or after it is started, but I can't find where.
    I think it's in the AppConfig.xml file, right? Could you give me an example?
    Thanks,
    Stephane

    1st Declare your action. Here is a sample that manually calls the set data ready flag...
    <shell id="SetDataReadyFlag" host-id="ITL_Local" >
    <command>${ENDECA_PROJECT_DIR}\control\set_baseline_data_ready_flag.bat</command>
    </shell>
    then in your custom tasks (or even the tasks that are part of the deploy template), you can call it....
    <script id="BaselineBuildDataFiles">
         <bean-shell-script>
         <![CDATA[
             // Get data
                // Verify Data
                // Set endeca data ready flag
             SetDataReadyFlag.run();
         ]]>
         </bean-shell-script>
    </script>
    The only thing I don't think you can do is get a response from the external call that you make. In that case I usually have my .bat, .exe, etc Write out a result file and then I read and parse the results from that.
    Hope this helps

  • How can I create a new layer that is a gradient?

    Hi, i'm very new to photoshop scripting and am having some trouble.
    I'm looking for a way to take an image i have and set it to have a gradient opacity as it approaches the middle, my thought on how to do that was to just create a layer that is a gradient from top left to bottom right and then attach that as a vector mask.
    Any ideas on how I could create this gradient layer in script, or a better method of doing this opacity gradient?
    Thanks in advance,
    Levianth

    You could try this:
    // 2012, use it at your own risk;
    #target photoshop
    if (app.documents.length > 0) {
    var myDocument = app.activeDocument;
    var theLayer = myDocument.activeLayer;
    if (theLayer.isBackgroundLayer == true) {theLayer.isBackgroundLayer = false};
    // create gradient layer;
    // =======================================================
    var idMk = charIDToTypeID( "Mk  " );
        var desc15 = new ActionDescriptor();
        var idnull = charIDToTypeID( "null" );
            var ref3 = new ActionReference();
            var idcontentLayer = stringIDToTypeID( "contentLayer" );
            ref3.putClass( idcontentLayer );
        desc15.putReference( idnull, ref3 );
        var idUsng = charIDToTypeID( "Usng" );
            var desc16 = new ActionDescriptor();
            var idType = charIDToTypeID( "Type" );
                var desc17 = new ActionDescriptor();
                var idType = charIDToTypeID( "Type" );
                var idGrdT = charIDToTypeID( "GrdT" );
                var idLnr = charIDToTypeID( "Lnr " );
                desc17.putEnumerated( idType, idGrdT, idLnr );
                var idGrad = charIDToTypeID( "Grad" );
                    var desc18 = new ActionDescriptor();
                    var idNm = charIDToTypeID( "Nm  " );
                    desc18.putString( idNm, "Custom" );
                    var idGrdF = charIDToTypeID( "GrdF" );
                    var idGrdF = charIDToTypeID( "GrdF" );
                    var idCstS = charIDToTypeID( "CstS" );
                    desc18.putEnumerated( idGrdF, idGrdF, idCstS );
                    var idIntr = charIDToTypeID( "Intr" );
                    desc18.putDouble( idIntr, 4096.000000 );
                    var idClrs = charIDToTypeID( "Clrs" );
                        var list3 = new ActionList();
                            var desc19 = new ActionDescriptor();
                            var idClr = charIDToTypeID( "Clr " );
                                var desc20 = new ActionDescriptor();
                                var idRd = charIDToTypeID( "Rd  " );
                                desc20.putDouble( idRd, 0.000000 );
                                var idGrn = charIDToTypeID( "Grn " );
                                desc20.putDouble( idGrn, 0.000000 );
                                var idBl = charIDToTypeID( "Bl  " );
                                desc20.putDouble( idBl, 0.000000 );
                            var idRGBC = charIDToTypeID( "RGBC" );
                            desc19.putObject( idClr, idRGBC, desc20 );
                            var idType = charIDToTypeID( "Type" );
                            var idClry = charIDToTypeID( "Clry" );
                            var idUsrS = charIDToTypeID( "UsrS" );
                            desc19.putEnumerated( idType, idClry, idUsrS );
                            var idLctn = charIDToTypeID( "Lctn" );
                            desc19.putInteger( idLctn, 0 );
                            var idMdpn = charIDToTypeID( "Mdpn" );
                            desc19.putInteger( idMdpn, 50 );
                        var idClrt = charIDToTypeID( "Clrt" );
                        list3.putObject( idClrt, desc19 );
                            var desc21 = new ActionDescriptor();
                            var idClr = charIDToTypeID( "Clr " );
                                var desc22 = new ActionDescriptor();
                                var idRd = charIDToTypeID( "Rd  " );
                                desc22.putDouble( idRd, 0.000000 );
                                var idGrn = charIDToTypeID( "Grn " );
                                desc22.putDouble( idGrn, 0.000000 );
                                var idBl = charIDToTypeID( "Bl  " );
                                desc22.putDouble( idBl, 0.000000 );
                            var idRGBC = charIDToTypeID( "RGBC" );
                            desc21.putObject( idClr, idRGBC, desc22 );
                            var idType = charIDToTypeID( "Type" );
                            var idClry = charIDToTypeID( "Clry" );
                            var idUsrS = charIDToTypeID( "UsrS" );
                            desc21.putEnumerated( idType, idClry, idUsrS );
                            var idLctn = charIDToTypeID( "Lctn" );
                            desc21.putInteger( idLctn, 4096 );
                            var idMdpn = charIDToTypeID( "Mdpn" );
                            desc21.putInteger( idMdpn, 50 );
                        var idClrt = charIDToTypeID( "Clrt" );
                        list3.putObject( idClrt, desc21 );
                    desc18.putList( idClrs, list3 );
                    var idTrns = charIDToTypeID( "Trns" );
                        var list4 = new ActionList();
                            var desc23 = new ActionDescriptor();
                            var idOpct = charIDToTypeID( "Opct" );
                            var idPrc = charIDToTypeID( "#Prc" );
                            desc23.putUnitDouble( idOpct, idPrc, 0.000000 );
                            var idLctn = charIDToTypeID( "Lctn" );
                            desc23.putInteger( idLctn, 0 );
                            var idMdpn = charIDToTypeID( "Mdpn" );
                            desc23.putInteger( idMdpn, 50 );
                        var idTrnS = charIDToTypeID( "TrnS" );
                        list4.putObject( idTrnS, desc23 );
                            var desc24 = new ActionDescriptor();
                            var idOpct = charIDToTypeID( "Opct" );
                            var idPrc = charIDToTypeID( "#Prc" );
                            desc24.putUnitDouble( idOpct, idPrc, 100.000000 );
                            var idLctn = charIDToTypeID( "Lctn" );
                            desc24.putInteger( idLctn, 2048 );
                            var idMdpn = charIDToTypeID( "Mdpn" );
                            desc24.putInteger( idMdpn, 50 );
                        var idTrnS = charIDToTypeID( "TrnS" );
                        list4.putObject( idTrnS, desc24 );
                            var desc25 = new ActionDescriptor();
                            var idOpct = charIDToTypeID( "Opct" );
                            var idPrc = charIDToTypeID( "#Prc" );
                            desc25.putUnitDouble( idOpct, idPrc, 0.000000 );
                            var idLctn = charIDToTypeID( "Lctn" );
                            desc25.putInteger( idLctn, 4096 );
                            var idMdpn = charIDToTypeID( "Mdpn" );
                            desc25.putInteger( idMdpn, 50 );
                        var idTrnS = charIDToTypeID( "TrnS" );
                        list4.putObject( idTrnS, desc25 );
                    desc18.putList( idTrns, list4 );
                var idGrdn = charIDToTypeID( "Grdn" );
                desc17.putObject( idGrad, idGrdn, desc18 );
            var idgradientLayer = stringIDToTypeID( "gradientLayer" );
            desc16.putObject( idType, idgradientLayer, desc17 );
        var idcontentLayer = stringIDToTypeID( "contentLayer" );
        desc15.putObject( idUsng, idcontentLayer, desc16 );
    executeAction( idMk, desc15, DialogModes.NO );
    // move layer below;
    var theGradient = myDocument.activeLayer;
    theGradient.move(theLayer, ElementPlacement.PLACEAFTER);
    // clipping mask;
    theLayer.grouped = true

Maybe you are looking for