Apply the shift via the script

Hello

from Toon Boom, I have many animations frame by frame vectored in the form of PDF files that need to be converted to SVG.

Using an Illustrator script I found on the web, it is no big deal.

This is the script:

/**********************************************************


ADOBE SYSTEMS INCORPORATED 
Copyright 2005-2010 Adobe Systems Incorporated 
All Rights Reserved 


NOTICE:  Adobe permits you to use, modify, and 
distribute this file in accordance with the terms
of the Adobe license agreement accompanying it.  
If you have received this file from a source 
other than Adobe, then your use, modification,
or distribution of it requires the prior 
written permission of Adobe. 


*********************************************************/


/**********************************************************

Save as SVGs.jsx


DESCRIPTION


This sample gets files specified by the user from the 
selected folder and batch processes them and saves them 
as SVGs in the user desired destination with the same 
file name.


Based on Adobe's "Save as PDFs" sample script, intended for Illustrator CS6

**********************************************************/


// Main Code [Execution of script begins here]


// uncomment to suppress Illustrator warning dialogs
// app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;


var destFolder, sourceFolder, files, fileType, sourceDoc, targetFile, svgSaveOpts;


// Select the source folder.
sourceFolder = Folder.selectDialog( 'Select the folder with Illustrator files you want to convert to SVG', '~' );


// If a valid folder is selected
if ( sourceFolder != null )
{
  files = new Array();
  fileType = prompt( 'Select type of Illustrator files to you want to process. Eg: *.ai', '*.pdf' );

  // Get all files matching the pattern
  files = sourceFolder.getFiles( fileType );

  if ( files.length > 0 )
  {
  // Get the destination to save the files
  destFolder = sourceFolder;
  for ( i = 0; i < files.length; i++ )
  {
  sourceDoc = app.open(files[i]); // returns the document object

  // Call function getNewName to get the name and file to save the SVG
  targetFile = getNewName();

  // Call function getSVGOptions get the SVGSaveOptions for the files
  svgSaveOpts = getSVGOptions( );

  // Save as svg
  sourceDoc.exportFile(targetFile, ExportType.SVG, svgSaveOpts );


  sourceDoc.close();
  }
  alert( 'Files are saved as SVG in ' + destFolder );
  }
  else
  {
  alert( 'No matching files found' );
  }
}




/*********************************************************


getNewName: Function to get the new file name. The primary
name is the same as the source file.


**********************************************************/


function getNewName()
{
  var ext, docName, newName, saveInFile, docName;
  docName = sourceDoc.name;
  ext = '.svg'; // new extension for svg file
  newName = "";

  for ( var i = 0 ; docName[i] != "." ; i++ )
  {
  newName += docName[i];
  }
  newName += ext; // full svg name of the file

  // Create a file object to save the svg
  saveInFile = new File( destFolder + '/' + newName );



  return saveInFile;
}




function getSVGOptions()
{
  var svgSaveOpts = new ExportOptionsSVG();


  //just using defaults aside from what's written below
  //see http://cssdk.host.adobe.com/sdk/1.0/docs/WebHelp/references/csawlib/com/adobe/illustrator/ExportOptionsSVG.html

  svgSaveOpts.embedRasterImages = true;

  return svgSaveOpts;
}

Due to some other issues, I am currently for any compensation my graphics using the object > path > offset in Illustrator and assigning a value of 0.001 mm.

I thought that it is the simplest solution, and after that, the graphics are perfectly fine.

The problem is that it is not only a few simple graphics, but animations with often more than 200 images (which would mean 200 PDF files to edit).

It manually all would be almost impossible.

So I'm wondering if there isn't a way to add the offset command to the script, so all of my PDF files have been applied all offset by being converted into SVG.

Would it be possible (I'm really hoping so)?

I just need a way to automate that. An action recording can be useful for some images, but I think rather in a batch operation.

Thank you!

but you can use actions on a lot!

Use the 'batch' option in the drop down palette menu actions. It allows you to perform an action on a folder of files.

Tags: Illustrator

Similar Questions

  • Sort by name via the script

    Hello world

    I would be grateful if someone could give some clues to sort by name from the

    Paragraph Styles, character Styles, Styles of object and panels color chart

    via the script.

    Thank you in advance.

    Edson Furman

    [email protected]

    To sort the styles I used the script below - works in CS3 and CS4 if it has been awhile since I finally tried. It could be coded with more elegance, but it worked well as it is. He does not account groups of style: I don't know what happens if your documents contain a sort you would better try.

    As for shades, these are not so easy to sort. There was a discussion about this at one of these sites:

    http://www.Hilfdirselbst.ch/gforum/gforum.cgi?jump=Forum%3d4

    http://InDesign-FAQ.de/

    Peter

    #target indesign
    
    sort_par_styles (app.documents[0]);
    sort_char_styles (app.documents[0]);
    sort_obj_styles (app.documents[0]);
    
    //-------------------------------------------------------------------------------
    
    function sort_par_styles (doc)
        {
        var string_array = sort_par_names (doc);
        for (var i = 0; i < string_array.length; i++)
            doc.paragraphStyles.item (string_array[i]).move (
                LocationOptions.after, doc.paragraphStyles[i+2])
        }
    
    function sort_par_names (doc)
      {
      var array = doc.paragraphStyles.everyItem().name;
      array.shift (); array.shift ();  // exclude [No p.] and [Basic p/]
      return array.sort (case_insensitive);
      }
    
    //-------------------------------------------------------------------------------
    
    function sort_char_styles (doc)
        {
        var string_array = sort_char_names (doc);
        for (var i = 0; i < string_array.length; i++)
            doc.characterStyles.item (string_array[i]).move (
                LocationOptions.after, doc.characterStyles[i+1])
        }
    
    function sort_char_names (doc)
      {
      var array = doc.characterStyles.everyItem().name;
      array.shift ();  // exclude [None]
      return array.sort (case_insensitive);
      }
    
    //-------------------------------------------------------------------------------
    
    function sort_obj_styles (doc)
        {
        var string_array = sort_obj_names (doc);
        for (var i = 0; i < string_array.length; i++)
            doc.objectStyles.item (string_array[i]).move (
                LocationOptions.after, doc.objectStyles[i+4])
        }
    
    function sort_obj_names (doc)
      {
      var array = doc.objectStyles.everyItem().name;
      array.shift (); array.shift (); array.shift ();  array.shift (); // exclude  [None], [Basic Graphics Frame], [Basic Text Frame], [Basic Grid]
      return array.sort (case_insensitive);
      }
    
    //-------------------------------------------------------------------------------
    
    function case_insensitive (a, b)
      {
      return a.toLowerCase() > b.toLowerCase()
      }
    
  • load via the script use

    Hello

    How can I charge a use (*.uri) via the script? Check the plug current if the plug-in is already loaded?

    Greetings,

    Martin

    Hi Martin

    The following will let you know what is the revision of a pluggin of data.

    The second function updates the plugin data upon request.

    Enjoy!

    Paul

    ' Gets the version of a use

    function GetDatapluginVersion (strDatapluginName)

    Dim oMyDataPlugin

    Set oMyDataPlugin = Navigator.Settings.RegisteredDataPlugins (strDatapluginName)

    GetDatapluginVersion = oMyDataPlugin.Version

    "Call the MsgBoxDisp (oMyDataPlugin.Version)."

    EndFunction

    Sub CheckUpdateAOP5

    Dim strAOP5CurrentVersion, strAOP5LatestVersion

    Dim MyVar

    protected path2AOP5: Path2AOP5 = 'Yours to fill. "

    strAOP5CurrentVersion = GetDatapluginVersion ("AOP5")

    strAOP5LatestVersion = "11.0.1f5081".

    If strAOP5CurrentVersion = strAOP5LatestVersion then

    ' msgbox ("AOP5 latest version:" & strAOP5LatestVersion & "is equivalent to" & strAOP5CurrentVersion)

    on the other

    MyVar = MsgBox ("AOP5 use requires an update now?", vbYesNo + vbQuestion, "DIAdem")

    Select if MyVar

    Case VbYes

    Call ExtProgram (Path2AOP5)

    Select end

    end if

    EndSub

  • Patch Vista - launch of the patches via the script

    I search for an answer online for days and finally gave up and decided to post here...

    I'm currently launching spots on our handful of machines Vista here via a script.  Each time, it returns the error "attempt to reference a token that does not exist.

    I tried to start by calling directly from the server, copy locally, mapping a drive to the server for the launch, etc... any attempt gives me this error even.  What happened to the multiple patches as well.

    Someone at - he seen elsewhere or have any ideas?

    UnderdogRC

    Thank you for visiting the website of Microsoft Windows Vista Community. The question you have posted is related to the server and would be better suited to the Technet community. Please visit the link below to find a community that will provide the support you want.

    http://TechNet.Microsoft.com/en-us/default.aspx Engineer Support Justin M. Microsoft Answers visit our Microsoft answers feedback Forumand let us know what you think.

  • Get and Set of dynamic Type via the Script output

    I am running vRO 6.0.1. I built a dynamic type to Veeam. I can see the items in the inventory and can select them as attributes in workflows. I'm looking to get the dynamic Type via a script object and set it as a variable in the script output, but its does not work. I created the dynamic type using the type dynamic plug-in generator v2.

    I have 'Veeam' namespace with types:

    VeeamHost

    jobFolder

    job

    I put an output with the 'DynamicTypes:Veeam.job' type attribute and the name jobOut

    My script is just:

    jobOut = Server.findForType ('DynamicTypes:Veeam.job' '29714267-f517-4f76-a621-902b3e789772/urn:veeam:Job:26eddcda-ea52-469b-b4c9-0b80fec098ae');

    System.log ("Job found:" + jobOut "'); 

    After the execution of the jobOut variable is empty. In the newspapers, I see:

    Found job: DynamicWrapper (Instance): [DynamicTypesDynamicObject]-[class com.vmware.o11n.plugin.dynamictypes.model.DynamicObject] - VALUE: dynobj: [__ns:Veeam __id:29714267-f517-4f76-a621-902b3e789772/urn:veeam:Job:26eddcda-ea52-469b-b4c9-0b80fec098ae __tp:DynamicTypes:Veeam.job]

    Does anyone have an idea of how complete the release of DynamicTypes:Veeam.job with the actual work of veeam I got via the script?

    Could check you what happens if you replace the line

    jobOut = Server.findForType("DynamicTypes:Veeam.job","29714267-f517-4f76-a621-902b3e789772/urn:veeam:Job:26eddcda-ea52-469b-b4c9-0b80fec098ae");

    with

    jobOut is DynamicTypesManager.getObject ("Veeam", "task", "29714267-f517-4f76-a621-902b3e789772/urn:veeam:Job:26eddcda-ea52-469b-b4c9-0b80fec098ae");.

  • Help with a script that detects the content in a cell and apply the cell style to line

    Hello


    I am trying to add an article to my table formatting script that is a cell with the word 'Budget' (but this can be written as ' Budget:' or ' Budget: (E) "- but without the speech marks) and apply the cell Style - SponsorCells - to all the cells of the whole line. I currently have on what it will, but it does not work:


    function checkWhichTable()
    {
    // ensure the user made a selection
    if (app.selection.length != 1)
    return null;
    var currentTable = app.selection[0];
    if (currentTable.hasOwnProperty("baseline"))
    {
    currentTable = app.selection[0].parent;
    }
    while (currentTable instanceof Cell || currentTable instanceof Row || currentTable instanceof Column)
    currentTable = currentTable.parent;
    if (!(currentTable instanceof Table))
    {
    // No table selected
    return null;
    }
    return currentTable;
    }
    app.doScript(checkUserSelection, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Process Table");
    
    
    function checkUserSelection ()
    {
    var a_table = checkWhichTable();
    if (a_table == null)
    {
    if (confirm("No table selected. Do you want to process *all* tables?") == false)
    return;
    allTables = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
    for (aTable=0; aTable<allTables.length; aTable++)
    {
    processTable (allTables[aTable]);
    }
    } else
    {
    processTable (a_table);
    }
    }
    function processTable(table)
    {
    // do something here!
    
    
    //Set 1st Row Height
    table.rows[0].height = "30mm";
    
    
    //Find Text in Cell and apply Cell Style to Row 
    var  
      myCellText=['Budget', 'Budget:', 'Budget: (E)'];  
     var myRegEx = new RegExp("^("+myCellText.join("|")+")$");
      for (i=0; i<table.cells.length; i++)
      {
        if (table.cells[i].texts[0].contents.match(myRegEx))
          table.cell[i].appliedCellStyle = "SponsorCells";
      }
    
    
    //end - do something here!
    }  
    


    I can get the script to apply the cell style to "SponsorCells" for each cell that contain the word 'Budget' etc, but I need cell ever on this line to have the cell style applied. I tried to re-write line 56 which applies the style to a cell, but I can't seem to make it work. Any help would be great.


    Separate on this issue, I would like to have a line of code similar to the 46 line, which sets the 1st height of lines, but I would like to say "If a cell has 'A cell Style' and then applies the value height 10 mm". If someone could result as a help of bonuses, things would be great double.


    Thanks in advance!

    But that could be painfully slow. To speed things up, follow these steps:

    var cells = table.cells.everyItem().getElements();
    for (var i=0; i
    

    It is faster, because it creates an array of cells with a call to table.cells, which is several times faster than calling table.cells. And before assigning to line 12mm height is useful to check if it is already 12 mm. checking things in InDesign and do things only when it is necessary is much more effective than simply doing things even if they are not necessary.

  • Help with a script to search for text in a table cell and apply the cell style

    Hello

    I build the script which Jongware wrote in his post here http://indesignsecrets.com/tackling-tables-through-scripting.php - I am trying to create a variable in which I can add a number of different parts of the text, in this case it's different parts of the United Kingdom i.e. 'London', 'East', 'Scotland' etc. I just need the script to apply the cell Style - 'District Cell' - to any cell that contains text in the variable. Here's the script, if anyone can help I would be grateful.

    function checkWhichTable()
    {
    // ensure the user made a selection
    if (app.selection.length != 1)
    return null;
    var currentTable = app.selection[0];
    if (currentTable.hasOwnProperty("baseline"))
    {
    currentTable = app.selection[0].parent;
    }
    while (currentTable instanceof Cell || currentTable instanceof Row || currentTable instanceof Column)
    currentTable = currentTable.parent;
    if (!(currentTable instanceof Table))
    {
    // No table selected
    return null;
    }
    return currentTable;
    }
    app.doScript(checkUserSelection, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Process Table");
    
    
    function checkUserSelection ()
    {
    var a_table = checkWhichTable();
    if (a_table == null)
    {
    if (confirm("No table selected. Do you want to process *all* tables?") == false)
    return;
    allTables = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
    for (aTable=0; aTable<allTables.length; aTable++)
    {
    processTable (allTables[aTable]);
    }
    } else
    {
    processTable (a_table);
    }
    }
    function processTable(table)
    {
    // do something here!
    
    
    //Find Text in Cell and apply Cell Style
    var textInCell=['London', 'Scotland', 'South West'];
    for (i=0; i<table.cells.length; i++)
    {
    if (table.cells[i].texts[0].contents==textInCell)
    table.cells[i].appliedCellStyle = "District Cell";
    }
    
    
    
    
    }
    

    Hello

    Change this feature:

    function processTable(table)
    {
    //Find Text (exactly as it is) in Cell and apply Cell Style
    var
      textInCell=['London', 'Scotland', 'South West'],
      mFound, cFound;
    
    app.findGrepPreferences = null;
    app.findGrepPreferences.findWhat = "^(" + cities.join("|") + ")$";
    mFound = table.findGrep();
    while( cFound = mFound.pop() )
      cFound.parent.appliedCellStyle = "District Cell";
    }
    

    Jarek

  • rendering image via the script get me uknown messege

    Hi all 2, maybe someone knows and can help me, what means of alert message and why it showing on 2 of my 7 work computers (all PC's have after effects cs5 but why only on two display this message?), when I try to make the current image via my script. My script - rendered the current image in the png file (and at this point after effect a bug and adding numbers 00000 filename so I need to find my rendered file and fix bug of file name and import file back), so when I see this message my script does not work (AE render the file, but the incorrect file name and my script is unable to import it to AE)

    PS to make the current image I create my own preset (with hands) for the output module based on the png sequence

    error.PNG

    THX

    Hi guys, I understand, the problem in my script make part, first of all I have the code to save the current image

    myProj.renderQueue.item (1) .outputModule (1) mpfprojectdir\dev10\src\csharp\projectbase.file = File (DesktopPath + "\\temp\\" + "_" + myLayerName); and it gives me error, so I fixed this alert message by

    ("myProj.renderQueue.item (1) .outputModule (1) mpfprojectdir\dev10\src\csharp\projectbase.file = File(DesktopPath+"\\1111\\"+"ltp"+"_"+myLayerName+"[###].png ");

    [#] .png - it's a key, thx to all!

  • Script to apply the IP address format

    Greetings,

    Acrobat Pro XI, in order to ensure that the user enters an IP address in the correct format, I have the following JavaScript called from tab Format text field properties by using a custom format script code.

    Validate the IPv4 address format

    var ipAdr = getField ("PHYSICAL IP ADDRESS");

    If (' event.value! = null & & event.value! = "") {}

    var re = / ^ \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;

    If (re.test (ipAdr.value) == false) {}

    App.Alert ("Please enter a valid IPv4 address");

    event.target.setFocus ();

    }

    }

    It seems to work, but I wonder:

    (1) it is ok to not have an else clause?

    (2) can the regular expression be improved?

    The regular expression seeks to apply the standard IPv4 dotted decimal notation that does not include the subnet mask.

    Thank you!

    There is no need for the command of setFocus. In addition, if you want to validate a value then you must use the Validate, not the event Format event.

    In the Validate event, you can also reject an incorrect value by setting event.rc false.

  • How to apply the expression using script?

    I use a script and an expression to automate all the layer selected to attend the control layer. So, I've do it now in two steps, first make a layer of control using this script:

    {

    model var = app.project.activeItem;

    var slctd_layer = comp.selectedLayers;

    var new_adjustment = comp.layers.addSolid ([1,1,1], "Control", comp.width, comp.height, comp.pixelAspect, comp.duration);

    new_adjustment.adjustmentLayer = true;

    var addSlider1 = app.project.activeItem.selectedLayers [0]. Effects.addProperty ("ADBE Slider Control");

    addSlider1.name = "time";

    addSlider1.property (1) .setValueAtTime (0, 0.06);

    var addSlider2 = app.project.activeItem.selectedLayers [0]. Effects.addProperty ("ADBE Slider Control");

    addSlider2.name = "opacity";

    addSlider2.property (1) .setValueAtTime (2, 0);

    addSlider2.property (1) .setValueAtTime (2.03, 100);

    }

    Then, I select all the layer under the control and apply the expression, for example:

    delay = thisComp.layer("Controler").effect ("delay") ("Slider") * index;

    t = time + delay;

    exp = thisComp.layer("Controler").effect ("opacity")("Slider").valueAtTime (t);

    exp;

    I'm working on an animation of the tight timelines and tons of materials with tons of layer for each model now. So I think that if it is possible to combine this stage two in a script that will automate this work for me. I'm still new to scripts and none need help with it. Thank you

    Like this:

    var ease = new KeyframeEase(0,100/6);    // speed (0 for easeIn or easeOut, influence range: 0-100)
    var addSlider1 = new_adjustment.effect.addProperty("ADBE Slider Control");
    addSlider1.name = "delay";
    // 1st key: value + ease
    addSlider1.property(1).setValueAtTime(0, 0.2);
    addSlider1.property(1).setTemporalEaseAtKey(1, [ease], [ease]);
    addSlider1.property(1).setInterpolationTypeAtKey(1, KeyframeInterpolationType.LINEAR, KeyframeInterpolationType.BEZIER);
    // 2nd key: value + ease
    addSlider1.property(1).setValueAtTime(2.03, 0.03);
    addSlider1.property(1).setTemporalEaseAtKey(2, [ease], [ease]);
    addSlider1.property(1).setInterpolationTypeAtKey(2, KeyframeInterpolationType.BEZIER, KeyframeInterpolationType.LINEAR);
    

    (The use of setInterpolationTypeAtKey is not necessary, it is only there to do things similar to what you would get by doing things by hand).

    Xavier

  • Script to apply the master spread

    Hello

    This Script is for the page master opener co applying everywhere where CN is applied, when we run the script, it warns Sucess.But master spread is not applied. Please resolve.

    var mydoc=app.activeDocument; 
    var mypara = mydoc.stories.item(0).paragraphs.everyItem().getElements();
    for(i=0; i<mypara.length; i++){
        if (myPara[i].appliedParagraphStyle.name=="CN"){
               mypara[i].parentTextFrames[0].parent.appliedMaster = mydoc.masterSpreads.item("CO-Opener");
            }
        }
    alert("Master Page applied Sucessfully")
    

    Hi Math,

    I hope that your code is correct, but it seems [0] stories have no Styles "CN".

    Change the threshold:

    var = mydoc.stories.item mypara (0).paragraphs.everyItem () .getElements ();

    in

    var mypara = mydoc.stories.everyItem ().paragraphs.everyItem () .getElements ();

    Thanks Jongware and Green4ever...

    and also the use of the below url to get coding right for CS4 and CS5 and higher

    Apply the Master Page by using the paragraph Style

    var myDocument = app.activeDocument;
    var myParas = myDocument.stories.everyItem().paragraphs.everyItem().getElements();
    var myPage = myDocument.pages;
    for(i=0; i
    

    Concerning

    Siraj

  • A script to apply the style of cell to whole lines containing specific text

    Hello

    I use InDesign CC 2014

    Does anyone know how apply a cellstyle based on the content of text found in a cell in javascript?

    I need to find the document and change cell style in the entire line to 'cellStyle01' If the 'etc' text appears in the cell.

    I found a similar script here to the forum which apply the table style, but do not know how to change it to apply the cell style!

    var curDoc = app.activeDocument;
    var allTables = curDoc.stories.everyItem().tables.everyItem();
      
    app.findTextPreferences = app.changeTextPreferences = null;
    app.findTextPreferences.findWhat = "someText";
    var allFounds = allTables.findText();
    app.findTextPreferences = app.changeTextPreferences = null;
      
    for ( var i = 0; i < allFounds.length; i++ ) {
    var curFound = allFounds[i];
    if ( curFound.length == 1 ) {
    var curFoundParent = curFound[0].parent;  
    // curFoundParent.parent.appliedTableStyle = curDoc.tableStyles.itemByName( "tableStyle" );  
    curFoundParent.parent.appliedCellStyle = curDoc.cellStyles.itemByName("cellStyle01");  
    }
    }
    
    

    Thank you!

    Hello

    in this new case, you can't just change the last line, because yo I want to find not the entire table and lines and cells.

    Try this modified version:

    var curDoc = app.activeDocument;
    var allTables = curDoc.stories.everyItem().tables.everyItem(); 
    
    app.findTextPreferences = app.changeTextPreferences = null;
    app.findTextPreferences.findWhat = "some Text";
    var allFounds = allTables.findText();
    app.findTextPreferences = app.changeTextPreferences = null;
    
    for ( var i = 0; i < allFounds.length; i++ ) {
        var tableFound = allFounds[i];
        if ( tableFound.length > 0 ) {
            for ( var j = 0; j < tableFound.length; j++ ) {
                var curFound = tableFound[j];
                var cellsInRow = curFound.parent.parentRow.cells.everyItem();
                cellsInRow.appliedCellStyle = curDoc.cellStyles.itemByName( "cellStyle01" );
                cellsInRow.clearCellStyleOverrides( true );
            } // end for
        } // end if
    } // end for
    
  • How to write the script to apply the character style?

    Hello

    I'm on a Macbook pro and without a numeric keypad, so I can't assign a shortcut to character styles. I heard a roundabout solution where you can assign a shortcut to a script that applies the character styles. Can anyone write this script?

    My character style is called "features"bold. "

    I am new to scripting, sorry if this is a stupid question.

    See you soon

    Hello

    1. save this code as a file inside your Script Panel folder .jsx

    2. apply a shortcut using the menu Edit: shortcuts...

    Option to choose:

    • suggest you choose an option 'background': 'Text', so you can use several shortcuts that are occupied in other contexts.
    #target indesign
    if (app.selection && app.selection[0].hasOwnProperty ("baselineShift") ) {
      var cName = "Features bold";
      var mCstyle = app.activeDocument.characterStyles.item(cName);
      if (mCstyle.isValid)
           app.selection[0].applyCharacterStyle(mCstyle);
      else
           alert ("CharStyle: " + cName + " not found");
      }
    else
      alert ("Some text supposed to be selected...");
    

    Jarek

  • Precomposer new function AE CC via the script

    As we know new AE CC got awesome box called "Adjust duration of both extended the selected layer composition".

    The default setting in the script guide is:

    [object LayerCollection] .precompose (array, string, [bool]);


    But it does not work with a new checkbox.

    So how to operate with a new checkbox via the script?

    Thanks for reading.

    I found that precomp function does not work with app.project.activeItem.selectedLayers;

    So here's the finishing touch that works with selected layers.

    See you soon

    
    function precompLayer() {
    var myComp = app.project.activeItem;
    if(myComp == null){alert("Please, select your composition"); return false;}
    
       var selectLayers = app.project.activeItem.selectedLayers; // selected
       if(selectLayers.length <1 ){alert("Please, select layers"); return false;}
    
       myLayers = [];      // precomp function works only with layers indexes, so array should contain layers indexes
    
            for (var l = 0; l< selectLayers.length; l++){
                myLayers.push(selectLayers[l].index);            // new array with layers indexes
            }
    
     var precompIndices = myLayers;  //change this to customize
            var precompName = "new_comp";  //change this to customize
            var parentComp = app.project.activeItem;  //change this to customize
            clearOutput();
            writeLn("Creating precompose");
            app.beginUndoGroup("Precompose");
            var Inpoint = 0;
            var Outpoint = 0;
    
            var precomp = parentComp.layers.precompose(precompIndices, precompName, true);
            var adjustStartTime = precomp.duration, newCompDuration = 0;
            writeLn(precomp.layers.length+" layers in procompose");
    
            for(var i=1; i<=precomp.layers.length; i++) {
                var layer = precomp.layer(i);
    
                (Inpoint > layer.inPoint) ? Inpoint = layer.inPoint : Inpoint;                  // begin of precomp
                (Outpoint < layer.outPoint) ? Outpoint = layer.outPoint : Outpoint;       // end of precomp
    
                var duration = Outpoint - Inpoint;
                adjustStartTime = adjustStartTime > layer.inPoint ? layer.inPoint : adjustStartTime;
                newCompDuration = newCompDuration < duration? duration : newCompDuration;
            }
                writeLn("New duration = "+newCompDuration);
    
            for(var i=1; i<=precomp.layers.length; i++) {
                precomp.layer(i).startTime -= adjustStartTime;
            }
    
            precomp.duration = newCompDuration;
            parentComp.layer(precompName).startTime = adjustStartTime;
            app.endUndoGroup();
    
    writeLn("Done!");
    }
    precompLayer();
    
  • Help: apply different styles of Pará to several consecutive paragraphs using the script

    Hi all

    I need to apply different styles of Pará to several consecutive paragraphs using the script, something like this (found somewhere on the net):

    myDoc = app.documents var [0];

    mySel var = app.selection [0];

    var myPStyle1 = "A";

    var myPStyle2 = 'B ';.

    you need to add 6 styles here:

    var myPStyle3 = 'C ';

    var myPStyle4 = "D";

    var myPStyle5 = 'E ';

    var myPStyle6 = 'F';

    var myPStyle7 = "G";

    var myPStyle8 = 'H ';

    the last style is not necessary in the script?

    apply style 1 paragraph 1

    mySel.appliedParagraphStyle = myDoc.paragraphStyles.item (myPStyle1);

    apply styles to the paragraphs after selection

    style 2

    mySel.paragraphs [-1] .insertionPoints [-1] .appliedParagraphStyle = myDoc.paragraphStyles.item (myPStyle2);

    next style

    mySel.paragraphs [-1] .insertionPoints [-1] .paragraphs [0] .insertionPoints [-1] .appliedParagrap hStyle = .nextStyle myDoc.paragraphStyles.item (myPStyle2);

    I tried a lot, but could not find the way to extend the sequence

    Sorry, no skills in the scripts still...

    all styles have "Next Style" option enabled, but I can't use ' apply style, then next style "or object styles, because I need four different sequences of these paragraph styles:

    A-B-C-D-E-F-G-H

    A-B-D-E-G-H

    A-C-D-F-G-H

    A-D-G-H

    and I don't really want to create special clones of the same style for each sequence (Keep It Simple, they say ).

    I think that this can be done through four slightly adjusted scripts...

    any suggestions would be greatly appreciated...

    Sorry to be late to the party, I usually take up such things immediately.

    How about this one?

    1. no separate necessary script, it uses a small dialog box where you can choose what style to use. If I'm not mistaken, you can press a digit key on Windows to immediately select one of the items.

    2. it works down in the paragraph in that your cursor is located. It has nothing to do with the blocks of text, even if - consecutive paragraphs within a story always ignore the text frames.

    3. extensible: you can easily change the names of the styles in the table at the top of the page and the number of groups of style in the list.

    var styleLists = [
              [ "A", "B", "C", "D", "E", "F", "G", "H" ],
              [ "A", "B", "D", "E", "G", "H" ],
              [ "A", "C", "D", "F", "G", "H" ],
              [ "A", "D", "G", "H" ]
    ];
    
    var radiobutts = [];
    
    styleDialog = app.dialogs.add ({name:"Set Multiple Styles",canCancel:true});
    with (styleDialog)
    {
              with (dialogColumns.add())
              {
                        with (radiobuttonGroups.add())
                        {
                                  for (i=0; i		   

Maybe you are looking for