How to align layers with scripts?

Hey people,

Maybe a little bit easy question, but I didn t find anything on the web to date.

I want to line up a few layers as with the Panel in "alignment" after effects interface. The goal is to vertical center forms.

Is it possible to do this without writing the calculation by myself?

See you soon

Lol you need to use the method of sourceRectAtTime() (available for any AVLayer) layers to understand the size and placement of the layers and then do the math yourself.

Tags: After Effects

Similar Questions

  • How to align layers on work plans

    Hello community,

    I try to vertical center align a layer with the rectangle branding tool, but the layer always align to the artboard?

    Hope for help,

    Lars

    Lars salvation,

    What you try to align the layer for? You can align it with the canvas/work plan (if only a layer is selected in the layers panel), either from another layer (if two or more layers are selected in the layer panel). You can't align it with a selection.

    If you need to align a rectangular selection, create a new temporary empty layer and fill the selection with this layer. Next, align the target to your new temporary layer layer.

    I hope that helps!

    Mike

  • How to align layers based on a specific layer

    Hello.

    I just watched this tutorial explaining everything by aligning the layers: https://helpx.adobe.com/photoshop/how-to/photoshop-align-images-multiple-layers.html#

    But, how do I align layers based on a specific layer? Let's say I have a layer about one-third from the left. I have 3 other layers, by going to halfway all the way to the right, I want to be centered based on this layer which is one third of the left, how should I do this? I want to use a specific layer as an anchor for the rest of the layers, regardless of the position of the layer anchor.

    I hope I'm using the right words, explaining what I want to do.

    Deon

    You can link layers and use one for the sorting of the anchor to speak.

    Maybe if you posted a screenshot of what you want to do.

    In any case, here is an example.

    Select the layer, press the layers of link at the bottom of the layers panel and then click on the layer in the layers panel, you want to use as anchor.

    Select the tool, then use the alignment buttons to align the blue layer in this example.

    Can also be used benchmarks commented to align the layers.

  • How to properly interact with script files?

    Hi all .

    I want to make sure that after a treatment in the script changed State of control elements (buttons, input fields). But access to the Properties something got only in main.js. Et treatment in most will be in the file hostscript. jsx .

    For example, btn_test1 does not show Properties, and btn_test1 Watch. How to interact with js files and How to access the properties of objects in the resource file hostscript. jsx

    Edraw Mind Map (Free Version) - ww1.jpg

    Thanks for the quick response. I found a solution... Jsx file returns 'result' = button name blocked, which is applied to the element. For a single key, just for a few - have need to pass an array

    HTML

    JS

    $("#btn_test1").click (function () {}

    csInterface.evalScript ('sayHello ()', {function (result)})

    document.getElementById ("result") .disabled = true;

    });

    JSX

    function SayHello () {}

    Return ("btn_test2");

    }

  • How to copy layers with objects as new objects

    Hey guys, no there's a good chance I'll be here, but thick:

    When I copy layers and modify objects on stage, things change also in the other layers.

    How to duplicate a layer so that I can change it with the objects of the old layer being affected? There must be a really easy way?

    I did a lot of research of this forum and google and have failed to find anything.

    Any help appreciated,

    Thank you.

    Yes, if you copy all objects frameworks in these frames are duplicated.

  • How to align subregions, with other primary areas

    I use Apex 5.0.2 and I have a relationship with the 4 main regions of the html and 2 html under regions. The image what it looks like now can be found below:Regions.PNG

    Subregion of L and R sub-region is under a parent called area 2(which is a region with no title).

    The purpose of having the Subregion L and R subregion is because they must be presented side-by-side.

    My problems is that L subregion is shifted to the right in a way and I tried to play with the Column Atrributes and attributes of the region , but it doesn't seem to work.

    How do L subregion in line with other major regions? Thank you!

    It depends on the theme you are using (it does not resemble universal theme). Use a toolbar developer to look at the CSS used for the subregion. For example, in a universal theme, it's the CSS that adds the padding:

    There are several ways to change this. If it's just for this page, you can add CSS inline to the page:

    This will change this:

    to do this:

  • How to highlight an array of layers Extend script for sequels (as the mouse)?

    Can someone please share how to select a layer in after effects, like the mouse click.

    var activeItem = app.project.activeItem;

    var curTime = app.project.activeItem.time;

    var myLayers = activeItem.layers;

    var layersAtTime = [];

    for (i = 1; i < = myLayers.length; i ++) {}

    {if (myLayers [i] .activeAtTime (curTime))}

    layersAtTime [layersAtTime.length] = myLayers [i];

    }

    }

    for (j = 0; j < layersAtTime.length; j ++) {}

    layersAtTime [j]. ???

    }

    Now how to highlight layers in the layersAtTime table in after effects just like the mouse click Select. ??

    If you do not need to do other thing with these layers (IE if you want only to select), you can simply do:

    for (i = 1; i<>

    myLayers [i] .selected = myLayers [i] .activeAtTime (curTime);

    };

    He made sure no active layers are not selected.

    Xavier.

  • How to get all the style of paragraphs and their policies of an indesign file and write all the info with info para in a txt file with scripts

    @

    How to get everyone how to get all the style of paragraphs and their policies of an indesign file and write all the info with info para in a txt file with scriptingstyle and their policies of an indesign file and write all the info with info para in a txt file with scripts

    Hello

    Try this,

    var doc = app.activeDocument,
        pstyles = doc.allParagraphStyles,
        report = "";
    for(var i =0;i
    

    Kind regards

    Cognet

  • How to align the text with fields of the table values

    Hi friends

    My Baisc requirement is to display some values of address with some raising in boxes at the same level as the half left of the page displays address and other half right side of the page displays the values in the boxes, but when I created a table to display the value in boxes, he does not insert text of the Ant at the same level on half of the page as my requirement is

    My requirement is

    AddressAddressAddressAddress val in a val in a box2 box1 / / I m not able to display any square here box
    AddressAddressAddressAddress val in a box3 val in a box of 4
    AddressAddressAddressAddress val in a val in a box6 box5
    AddressAddressAddressAddress val in a val in a box8 box7

    but it comes as

    Val in a val in a box2 box1 / / I m not able to display any square here box
    Val in a box3 val in a box of 4
    Val in a val in a box6 box5
    Val in a val in a box8 box7
    AddressAddressAddressAddress
    AddressAddressAddressAddress
    AddressAddressAddressAddress
    AddressAddressAddressAddress

    and that's my problem I do not know how to align bot at the same level, any advice would be very help full

    Thanks in advance

    Thank you
    Pratap

    You can send me your sample xml and RTF, it would be better that I can see the RTf.

  • How to remove master page with script elements

    I want to remove items from the master page with script

    app.activeDocument. masterPageItems.remove ();

    and there are items on the master page to remove all the and I want to create a new one (rectangle frame or text)

    Try this,

    var myDoc = app.activeDocument;  
    
    for(var i=0; i< myDoc.masterSpreads.length; i++)
    {
        for(var j=myDoc.masterSpreads[i].pageItems.length-1; j>=0 ; j--)
        {
            myDoc.masterSpreads[i].pageItems[j].remove()
        }
    }
    

    Vandy

  • Flex 4: how 2 set Application width/height with Script?

    I'm new to Flex 4 and going through the pain of migration of 3 to 4.

    I need to set the size of my application programmatically. In Flex 3, I made this way:

    mx.core.Application.application.width = theWidth; (equivalent to the height).

    I don't know how to do this with Flex 4. Searched high and low.

    Help, please! TIA

    Bruce

    You can use the this.width, this.height and properties.

  • How to align the position of a node in a pane of the grid using CSS?

    Hello

    I have an interface defined in FXML:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <?import java.lang.*?>
    <?import javafx.scene.*?>
    <?import javafx.scene.control.*?>
    <?import javafx.scene.layout.*?>
    
    <BorderPane xmlns:fx="http://javafx.com/fxml" >
        <center>
            <GridPane alignment="top_center" hgap="8" prefWidth="450" vgap="8" style="-fx-padding: 10;" >
                <styleClass>
                    <String fx:value="form"/>
                </styleClass> 
                        
                <children>
    
                    <Label text="From" GridPane.columnIndex="0" GridPane.rowIndex="0" />
                    <TextField fx:id="from" GridPane.columnIndex="1" GridPane.rowIndex="0"/>
    
                    <Label text="Recipient(s)" GridPane.columnIndex="0" GridPane.rowIndex="1" />
                    <TextField fx:id="recipients" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
                    
                    <Label text="Subject (defaults to title)" GridPane.columnIndex="0" GridPane.rowIndex="2" />
                    <TextField fx:id="subject" GridPane.columnIndex="1" GridPane.rowIndex="2"/>                   
                    
                    <Label text="Send mail as ..." GridPane.columnIndex="0" GridPane.rowIndex="3" />
                    <ListView fx:id="mail_format" prefHeight="100" GridPane.columnIndex="1" GridPane.rowIndex="3" />  
                    
                    <Label text="Plain Text Mail" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.halignment="center" GridPane.rowIndex="4" />                  
                    
                    <Label text="Template" GridPane.columnIndex="0" GridPane.rowIndex="5" />
                    <TextField fx:id="plain_template" GridPane.columnIndex="1" GridPane.rowIndex="5"/>                
                                      
                    <Label text="Send as is (do not dump into plain text)" GridPane.columnIndex="0" GridPane.rowIndex="6" />
                    <CheckBox fx:id="plain_noconvert" GridPane.columnIndex="1" GridPane.rowIndex="6"/>
                    
                    <Label text="HTML Mail" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.halignment="center" GridPane.rowIndex="7" />
                                    
                    <Label text="Template" GridPane.columnIndex="0" GridPane.rowIndex="8" />
                    <TextField fx:id="html_template" GridPane.columnIndex="1" GridPane.rowIndex="8"/>               
    
                    <Label text="Other configuration" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.halignment="center" GridPane.rowIndex="9" />
                    
                    <Label text="Reply-To" GridPane.columnIndex="0" GridPane.rowIndex="10" />
                    <TextField fx:id="reply_tos" GridPane.columnIndex="1" GridPane.rowIndex="10"/>
                    
                    <Label text="Cc" GridPane.columnIndex="0" GridPane.rowIndex="11" />
                    <TextField fx:id="ccs" GridPane.columnIndex="1" GridPane.rowIndex="11"/>
                    
                    <Label text="Bcc" GridPane.columnIndex="0" GridPane.rowIndex="12" />
                    <TextField fx:id="bccs" GridPane.columnIndex="1" GridPane.rowIndex="12"/>
                    
                    <Label text="HTML base (defaults to current server)" GridPane.columnIndex="0" GridPane.rowIndex="13" />
                    <TextField fx:id="html_base" GridPane.columnIndex="1" GridPane.rowIndex="13"/>
                                                                                                                   
                    
                </children>
            </GridPane>
        </center>
    </BorderPane>
    I want to align the labels to right using CSS:
    .form *.label {
      -fx-alignment: right;
      -fx-font-weight: bold;
      -fx-hpos: right;
      -fx-text-alignment: right;
      -fx-text-wrap: true;
    }
    However I have not found any way to align the labels in the GridPane using CSS, or - fx-alignment: right, - fx-node-hpos: right. -fx-hpos: right. -fx-text-alignment: seem to work well...


    The only way to make it work is to define the attribute of each label Grid.halignment:
                    <Label text="HTML Mail" GridPane.columnIndex="0" GridPane.columnSpan="2" GridPane.halignment="right" GridPane.rowIndex="7" />
    But what happens if I want to change that at a later stage-> I need to change this attribute for each node.


    How can align the labels to right using CSS only?

    Currently CSS in JFX cannot really be used for layout page (or calibration). This is one of those grey areas between what is style (which should be in the CSS) and what is layout (which should be in the FXML). I think I remember Richard mentioning once in a forum or an article that he did not want to add alignment stuff to the CSS at a certain point, but don't quote me on that. You might have a search through Kenai to see if there is a feature request for it and if not add one.

    Perhaps you could it with fake labels stretch to fill the available space in the GridPane. For this, you need to disable the restriction of maximum size (setMaxWidth and setMaxHeight to Integer.MAX_VALUE) and ensure your forced GridPane are such that the label will fill the cell. Once you have a stretched label alignment will come into play as the text is aligned relative to the area of the label (as opposed to a manager that aligns the entire label compared to its parent). I think that put a border on the label when debugging to work on what's going on.

    Another less confined but more flexible alternative might be to use variables in your FXML files. You can do this in a number of ways. We must create a bean that has all the variables of your on it with accessors get and then you can move it to your charger FXML namespace and then reference it by using things like ${myConstants.gridAlignment}. Another is to create static methods on a class that a node, these can then be called from the FXML using a notation similar to GridPane.alignment. This second approach only works for things where you want to work directly on the node, but for your scenario which should be ok I think. And then there is always the option to activate a script language in your FXML, allowing you to perform more nothing.

    Hope that helps,
    zonski

  • Align objects with precision

    One of my biggest problems in mxml involves the alignment of the text. In the code below, I would like to line up the bottom of the text fields, so the two fields are sitting at the same vertical height.

    Please tell me how to do this.

    Thank you.

    <? XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML " "layout = "absolute" creationComplete ="application1_creationCompleteHandler (event)" >
    < mx:Script >
    <! [CDATA]
    Import mx.events.FlexEvent;
    protected function application1_creationCompleteHandler(event:FlexEvent):void {}
    title.setStyle ("fontSize", 30)
    subtitle.setStyle ("fontSize", 14)
    }

    []] >
    < / mx:Script >
    < mx:HBox verticalAlign = "bottom" >
    < mx:Text id = "title" text = "Title" / >
    < mx:Text id = "subtitle" text = "subtitle" / >
    < / mx:HBox >
    < / mx:Application >

    I'm not sure that I am an expert in typography, but, having created nearly 1.5 (or same 1.6) fonts, I learned that each of them have their own settings (like the ascenders, descenders etc.)... Ripheriques align letters with zero police line. But in Flex, we deal with text fields, which are created for letters with their tops and tails (which have different lengths in different font sizes)...

    Yet less skilled in Flex, I'm not sure that there is an automatic proper solution...

    But you can align it manually by adding some padding (at least it works...)

    <>

    "xmlns:MX ="http://www.adobe.com/2006/mxml"

    layout ='

    absolute minWidth"="400 ".

    creationComplete = "application1_creationCompleteHandler (event)" "

    >

    Import mx.events.FlexEvent;

    protected function application1_creationCompleteHandler(event:FlexEvent):void {}

    title.setStyle ("fontSize", 30)

    subtitle.setStyle ("fontSize", 14)

    }

    ]]>

    P.S. I don't know why, but complete Manager for creating application wouldn't work, so I had to add font size definitions...

  • How to duplicate layers &amp; groups without automatically add a "copy", "copy 1", "# copy" at the end of the new group.

    How to duplicate layers & groups without automatically add a "copy", "copy 1", "# copy" at the end of the new group.

    He has been harassing me for a while now, since I often work with the same elements over and over again. His frustration of having to change the name of each layer manually, especially if I copy an entire group.

    Is there a setting in Photoshop or maybe an external script that can help solve this problem for me?

    See you soon,.

    Qiming

    You can go to the Forum script:

    http://forums.Adobe.com/thread/433759?TSTART=0

    http://forums.Adobe.com/message/1116182#1116182

  • How to sort layers by 123, instead, abc

    I have the script. including the layers of sort in order of abc.

    #target "Illustrator"
    
    
    /**
     * sort layers (with sublayer)
     */
    
    
    var doc = app.documents[0];
    var lay = doc.layers;
    var array_primary = [];
    for (var i=0, iL=lay.length; i < iL ; i++) {
      if (lay[i].layers.length === 0) {
      array_primary.push( lay[i].name );
      }
      else {
      array_primary.push( lay[i].name );
      var array_secondary = [];
      for (var j=0, jL=lay[i].layers.length; j < jL ; j++) {
      array_secondary.push(lay[i].layers[j].name);
      };
      var result2 = array_secondary.sort( function (a,b) { return a > b });
      // sort sublayers
      sort_layer (lay[i], result2);
      }
    };
    var result1 = array_primary.sort( function(a,b) { return a > b } );
    
    
    // sort layers
    sort_layer (doc, result1);
    
    
    function sort_layer (obj, array) {
      for (var ri=0, riL=array.length; ri < riL ; ri++) {
      obj.layers.getByName(array[ri]).zOrder( ZOrderMethod.SENDTOBACK );
      };
    }
    

    For example, I layer names:

    Layer # 116

    Layer # 12

    Layer # 117

    Layer # 32

    Layer n ° 3

    This script sorting like:

    Layer # 116

    Layer # 117

    Layer # 12

    Layer n ° 3

    Layer # 32

    But I want to make to increase:

    Layer n ° 3

    Layer # 12

    Layer # 32

    Layer # 116

    Layer # 117

    Please, help me to do right!

    Ch ch ch check it out!

    The sort function is changed out of the non-numeric characters and then analyse int to be able to sort by the number vs string.

    #target illustrator-20
    function test(){
      /**
      * sort layers (with sublayer)
      */
      function sortNumeric(a, b){
        a = a.replace(/[^\d]+/g, '');
        b = b.replace(/[^\d]+/g, '');
        return parseInt(a) > parseInt(b);
      };
    
      var doc = app.documents[0];
      var lay = doc.layers;
      var array_primary = [];
      for (var i=0, iL=lay.length; i < iL ; i++) {
        if (lay[i].layers.length === 0) {
        array_primary.push( lay[i].name );
        }
        else {
        array_primary.push( lay[i].name );
        var array_secondary = [];
        for (var j=0, jL=lay[i].layers.length; j < jL ; j++) {
        array_secondary.push(lay[i].layers[j].name);
        };
        var result2 = array_secondary.sort( sortNumeric);
        // sort sublayers
        sort_layer (lay[i], result2);
        }
      };
      var result1 = array_primary.sort( sortNumeric ); 
    
      // sort layers
      sort_layer (doc, result1); 
    
      function sort_layer (obj, array) {
        for (var ri=0, riL=array.length; ri < riL ; ri++) {
        obj.layers.getByName(array[ri]).zOrder( ZOrderMethod.SENDTOBACK );
        };
      }
    };
    test();
    

Maybe you are looking for