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

Execute Action in Script

Community Beginner ,
Feb 02, 2022 Feb 02, 2022

Copy link to clipboard

Copied

I have over 4000 single file and all of them are the same layername and group items.

 

As following screenshot, I want to write script and this script opens file and execute action that is recorded by me before. I coded but it has problem. It says this action can not run something like that. 

 

2022-02-02_14-28-11.png

 

Here is my code;

 

var sourceFolder, fileType, targetFile,destFolder, gridLayers,j,materialGridLayer;  
  
// Select the source folder.  
sourceFolder = Folder( '~/Desktop/Icon Pack/Export' );  
  
// If a valid folder is selected  
if ( sourceFolder != null )  
{  
    files = new Array();  
    fileType = ( '*.ai' );  
    
    // Get all files matching the pattern  
    files = sourceFolder.getFiles( fileType );  
   
    if ( files.length > 0 )  
    {  
        for ( i = 0; i < files.length; i++ )  
        {  
         
            sourceDoc = app.open(files[i]); // returns the document object  
            var mainLayers = sourceDoc.layers;
                        
            try
              {
 
                
                sourceDoc.activeLayer = mainLayers.getByName('Ana Ikonlar');    // variant 2

                var aLay = sourceDoc.activeLayer;
             
                var foregroundLayer =aLay.layers.getByName('foreground');

                var groudItemLayer = foregroundLayer.groupItems[0];
                
                groudItemLayer.selected = true;
             
                apps.doScript('actions_script','long_shadow_script');
             
                }
              catch(f)
              {

              }
            sourceDoc.close(SaveOptions.SAVECHANGES);  
        }  
    }  
    else  
    {  
        alert( 'Problem!!!' ); 
    }  
}  
TOPICS
Bug , Draw and design , Feature request , Import and export , Print and publish , Scripting , Third party plugins , Tools

Views

500

Translate

Translate

Report

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 , Feb 02, 2022 Feb 02, 2022

in addition, you seem to have the doScript arguments switched, it should be doScript ("action name", "set name")

 

change this

app.doScript('actions_script','long_shadow_script');

 

to this

app.doScript('long_shadow_script', 'actions_script');

Votes

Translate

Translate
Adobe
Valorous Hero ,
Feb 02, 2022 Feb 02, 2022

Copy link to clipboard

Copied

Try by changing this 

apps.doScript

to

app.doScript

 

Votes

Translate

Translate

Report

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
Community Beginner ,
Feb 02, 2022 Feb 02, 2022

Copy link to clipboard

Copied

Thank you, I did it but it says following error;

Object "play action" not available

2022-02-02_17-50-37.png

 

 

The task is

1-Open document

2-Select layer by name "Ana Ikonlar" and groutItem by name "foreground"

3-Play action by name "long_shadow" in "actions_script"

4-Save and close

 

4 steps and I couldn't manage script 😞 

 

Votes

Translate

Translate

Report

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
Community Expert ,
Feb 02, 2022 Feb 02, 2022

Copy link to clipboard

Copied

in addition, you seem to have the doScript arguments switched, it should be doScript ("action name", "set name")

 

change this

app.doScript('actions_script','long_shadow_script');

 

to this

app.doScript('long_shadow_script', 'actions_script');

Votes

Translate

Translate

Report

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
Community Beginner ,
Feb 02, 2022 Feb 02, 2022

Copy link to clipboard

Copied

LATEST

Oh this works. Thank you much. 

Votes

Translate

Translate

Report

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