How to fit text layer to extents of comp with scripting?

Hi There,
I'm trying to do something relatively simple, but am having trouble figuring out why it's not working.  I want a script that scales a text layer to the correct size so that it fits the extents of its parent comp.  I have found a couple of resources that do this, but I think these scripts assume that AE is running with its GUI.  In my case, I'm running afterfx.exe from a batch script with the -noui switch.  So, when running AE with the -noui switch, it seems that using the app.executeCommand() function doesn't seem to work right.  Here are the threads I found for handling exactly what I want, but that both incorporate the app.executeCommand() method:
http://www.aenhancers.com/viewtopic.php?f=8&t=150&start=45
and
http://aenhancers.com/viewtopic.php?f=8&t=150&start=60
Does anybody have any other suggestions for writing a script that fits a text layer to size, or are these the only alternatives out there?
Thank you for your time and help!

You don’t need to use app.executeCommand() for that any more. Something like this should work:
  var myComp = app.project.activeItem;
  var myLayer = myComp.layer(1);
  var myRect = myLayer.sourceRectAtTime(0,false);
  var myScale = myLayer.property("Scale").value;
  var myNewScale = [myScale[0]myComp.width/myRect.width,myScale[1]myComp.height/myRect.height];
  myLayer.property("Scale").setValue(myNewScale);
Dan

Similar Messages

  • ID cs6:How to Fit Frame to Version heart(or Page) with script?

    More times, I need my Frame fit to my Version,or fit to my page,
    I looking for the scrip in the Internet, only see "frames  to content"
    Who would like to help me?
    Thank you very much~

    Hi  Kai Rübsamen
    Thank  you very much.
    Some times I must press Ctrl+Z, It will  be ok?
    and ,I want to select more than one text frame.
    and, the script is wrong in some document ,Tested, I find  should be make the Coordinate origin to the The upper left corner
    Could you like to add this Function into the scrip.
    thanks
    fit to margins
    var curDoc = app.activeDocument;
    if ( app.selection.length != 1 ) {
        ( alert ( "Something wrong with your selection!" ) );
        exit();
    var curSel = app.selection[0];
    var curPage = curSel.parentPage;
    var rO = curDoc.viewPreferences.rulerOrigin;
    if (rO != 1380143215) {
        curDoc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
    var pW = curDoc.documentPreferences.pageWidth;
    var y1, x1, y2, x2;
    if ( curPage.side == PageSideOptions.leftHand ){
        x2 = curPage.marginPreferences.left;
        x1 = curPage.marginPreferences.right;
    else {
        x1 = curPage.marginPreferences.left;
        x2 = curPage.marginPreferences.right;
    x2 = pW - x2;
    var gB = curSel.geometricBounds;
    // fit to margins
    gB[1] = x1;
    gB[3] = x2;
    curSel.geometricBounds = gB;
    curSel.fit ( FitOptions.FRAME_TO_CONTENT );
    resetAsBefore();
    function resetAsBefore() {
        if ( rO != 1380143215 ) {
                curDoc.viewPreferences.rulerOrigin = rO;
    fit to page
    var curDoc = app.activeDocument;
    if ( app.selection.length != 1 ) {
        ( alert ( "Something wrong with your selection!" ) );
        exit();
    var curSel = app.selection[0];
    var curPage = curSel.parentPage;
    var rO = curDoc.viewPreferences.rulerOrigin;
    if (rO != 1380143215) {
        curDoc.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;
    var pW = curDoc.documentPreferences.pageWidth;
    var y1, x1, y2, x2;
    if ( curPage.side == PageSideOptions.leftHand ){
        x2 = curPage.marginPreferences.left;
        x1 = curPage.marginPreferences.right;
    else {
        x1 = curPage.marginPreferences.left;
        x2 = curPage.marginPreferences.right;
    x2 = pW - x2;
    var gB = curSel.geometricBounds;
    // fit to page
    gB[1] = 0;
    gB[3] = pW;
    curSel.geometricBounds = gB;
    curSel.fit ( FitOptions.FRAME_TO_CONTENT );
    resetAsBefore();
    function resetAsBefore() {
        if ( rO != 1380143215 ) {
                curDoc.viewPreferences.rulerOrigin = rO;
    best wishes

  • How do I text back and forth between iPads with only wifi capabilities

    How do I text back and forth between iPads with only wifi capabilities

    Using FaceTime http://support.apple.com/kb/ht4319http://support.apple.com/kb/ht4319
    Troubleshooting FaceTime http://support.apple.com/kb/TS3367http://support.apple.com/kb/TS3367
    The Complete Guide to FaceTime + iMessage: Setup, Use, and Troubleshooting
    http://tinyurl.com/a7odey8http://tinyurl.com/a7odey8
    Troubleshooting FaceTime and iMessage activation
    http://support.apple.com/kb/TS4268http://support.apple.com/kb/TS4268
    iOS: FaceTime is 'Unable to verify email because it is in use'
    http://support.apple.com/kb/TS3510http://support.apple.com/kb/TS3510
    Using FaceTime and iMessage behind a firewall
    http://support.apple.com/kb/HT4245http://support.apple.com/kb/HT4245
    iOS: About Messages
    http://support.apple.com/kb/HT3529http://support.apple.com/kb/HT3529
    Set up iMessage
    http://www.apple.com/ca/ios/messages/http://www.apple.com/ca/ios/messages/
    iOS and OS X: Link your phone number and Apple ID for use with FaceTime and iMessage
    http://support.apple.com/kb/HT5538http://support.apple.com/kb/HT5538
    How to Set Up & Use iMessage on iPhone, iPad, & iPod touch with iOS
    http://osxdaily.com/2011/10/18/set-up-imessage-on-iphone-ipad-ipod-touch-with-io s-5/http://osxdaily.com/2011/10/18/set-up-imessage-on-iphone-ipad-ipod-touch-with-io s-5/
    Set Up Alert Sounds
    http://www.quepublishing.com/articles/article.aspx?p=1873027&seqNum=3http://www.quepublishing.com/articles/article.aspx?p=1873027&seqNum=3
    Extra FaceTime IDs
    http://tinyurl.com/k683gr4http://tinyurl.com/k683gr4
    Troubleshooting Messages
    http://support.apple.com/kb/TS2755http://support.apple.com/kb/TS2755
    Troubleshooting iMessage Issues: Some Useful Tips You Should Try
    http://www.igeeksblog.com/troubleshooting-imessage-issues/http://www.igeeksblog.com/troubleshooting-imessage-issues/
    Setting Up Multiple iOS Devices for iMessage and Facetime
    http://macmost.com/setting-up-multiple-ios-devices-for-messages-and-facetime.htmhttp://macmost.com/setting-up-multiple-ios-devices-for-messages-and-facetime.htm l
    FaceTime and iMessage not accepting Apple ID password
    http://www.ilounge.com/index.php/articles/comments/facetime-and-imessage-not-acc epting-apple-id-password/http://www.ilounge.com/index.php/articles/comments/facetime-and-imessage-not-acc epting-apple-id-password/
    Fix Can’t Sign Into FaceTime or iMessage iOS 7
    http://ipadtutr.com/fix-login-facetime-imessage-ios-7/http://ipadtutr.com/fix-login-facetime-imessage-ios-7/
    FaceTime, Game Center, Messages: Troubleshooting sign in issues
    http://support.apple.com/kb/TS3970http://support.apple.com/kb/TS3970
    Unable to use FaceTime and iMessage with my apple ID
    https://discussions.apple.com/thread/4649373?tstart=90https://discussions.apple.com/thread/4649373?tstart=90
    How to Block Someone on FaceTime
    http://www.ehow.com/how_10033185_block-someone-facetime.htmlhttp://www.ehow.com/how_10033185_block-someone-facetime.html
    My Facetime Doesn't Ring
    https://discussions.apple.com/message/19087457#19087457https://discussions.apple.com/message/19087457#19087457
    How to watch FaceTime calls on the big screen with Apple TV
    http://www.imore.com/daily-tip-ios-5-airplay-mirroring-facetimehttp://www.imore.com/daily-tip-ios-5-airplay-mirroring-facetime
    Send an iMessage as a Text Message Instead with a Quick Tap & Hold
    http://osxdaily.com/2012/11/18/send-imessage-as-text-message/http://osxdaily.com/2012/11/18/send-imessage-as-text-message/
    To send messages to non-Apple devices, check out the TextFree app https://itunes.apple.com/us/app/text-free-textfree-sms-real/id399355755?mt=8https://itunes.apple.com/us/app/text-free-textfree-sms-real/id399355755?mt=8
    How to Send SMS from iPad
    http://www.iskysoft.com/apple-ipad/send-sms-from-ipad.htmlhttp://www.iskysoft.com/apple-ipad/send-sms-from-ipad.html
    How to Receive SMS Messages on an iPad
    http://yourbusiness.azcentral.com/receive-sms-messages-ipad-16776.htmlhttp://yourbusiness.azcentral.com/receive-sms-messages-ipad-16776.html
    Apps for Texting http://appadvice.com/appguides/show/apps-for-textinghttp://appadvice.com/appguides/show/apps-for-texting
    You can check the status of the FaceTime/iMessage servers at this link.
    http://www.apple.com/support/systemstatus/http://www.apple.com/support/systemstatus/
     Cheers, Tom

  • How to create a new Oracle OSB project automaticaly with script without IDE

    Hello,
    I want to create automatically an "Oracle service bus project" and an "Oracle service bus configuration project" with scripts (ANT or Maven or ...) without using IDE, without using workshop or Eclipse. I want to create automatically (ANT or Maven) just a skeleton of an OSB project witch i can use after in workshop.
    I want to create 1 "Oracle service bus configuration project" with many "Oracle service bus project" automatically (ANT or Maven or scripts) witch i can use after in workshop. How to create a new Oracle OSB project automaticaly with script without IDE ? How can i do this ?
    I'm using Oracle service bus 10.3.1
    Thank you for your help.

    Thank you for your response,
    I do not want to just create the services (proxy services and business services) but I want to create a template for 40 OSB project with the same scripts ANT/Maven.
    Template="Oracle service bus configuration project" + "Oracle service bus project" + services of 40 OSB projects
    The goal is that I have more than 40 projects to create and just the name of the projects that changes (when I say the name of the project ie the name of the OSB project, the name of proxy services and the name of business services ).
    So I want to give my script (ANT/Maven) the name of 40 OSB project and the script must generate the skeleton of the 40 projects at once time and after generation of skeleton of the 40 project, I will import them in the workshop to add manually mapping and routing and other things that differs from one project to another.
    So i want to generate automatically a skeletons of 40 OSB projects using a script (ANT / Maven) and I give to the script juste the names of the 40 projects.
    I want to create a "Oracle service bus configuration project" and "Oracle service bus project" automatically of 40 OSB projects (ANT or Maven or scripts) witch i can use after in workshop.
    I want to create one 'template' of all 40 projects in the same time, with the same directory structure (Transforlation, Business services, proxy services, WSDL .....) and all 40 project have the same transport, just the names of projects and services witch changes and i can give to the script all names of projects and services and i can give also all WSDL.
    Regards,
    Tarik

  • How can I Reconcile all tables on multiples mappings with scripting????

    I have OWB 9.2.0.2.8
    I have to reconcile all tables and external tables on multiple mappings.
    How can I do it with scripting language, please?
    Thanks very much in advance!!!!

    Good afternoon Claudio,
    Should be something like this:
    foreach mapName [OMBLIST MAPPINGS] {
      puts "Checking $mapName"
      foreach tabName [OMBRETRIEVE MAPPING '$mapName' GET TABLE OPERATORS] {
        puts "Reconciling $tabName"
        OMBRECONCILE TABLE '$tabName' \
          TO MAPPING '$mapName' \
          OPERATOR '$tabName' \
          USE (RECONCILE_STRATEGY 'REPLACE', MATCHING_STRATEGY 'MATCH_BY_OBJECT_ID');
    }If you want to alter reconcile and/or matching strategy, check documentation on OMBRECONCILE in the OWB Scripting Reference.
    Good luck, Patrick

  • How to add text vertically into a Word margin with C# (using namespace: Microsoft.Office.Interop.Word)

    I need to add text vertically in a word document outside the margins.  How can I do this with Microsoft.Office.Interop.Word and C#?
    Leonard Swarczinski Software Developer Postal Center International

    Hi Leonard,
    According to your description, do you want to add text vertically into Page Header/Footer? I wrote a sample  for you.
    using Microsoft.Office.Core;
    using Microsoft.Office.Interop.Word;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    namespace AddTextToWord
    class Program
    static void Main(string[] args)
    CreateNewDocument();
    Console.ReadLine();
    private static void CreateNewDocument()
    Object oMissing = System.Reflection.Missing.Value;
    Microsoft.Office.Interop.Word.Application oWord;
    Microsoft.Office.Interop.Word.Document oDoc;
    oWord = new Microsoft.Office.Interop.Word.Application();
    oWord.Visible = true;
    oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
    String HeaderText = "Hello everyone!";
    WdParagraphAlignment wdAlign = WdParagraphAlignment.wdAlignParagraphCenter;
    AddHeader1(oWord, HeaderText, wdAlign);
    private static void AddHeader1(Application WordApp, string HeaderText, WdParagraphAlignment wdAlign)
    Object oMissing = System.Reflection.Missing.Value;
    WordApp.ActiveWindow.View.Type = WdViewType.wdOutlineView;
    WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekPrimaryHeader;
    Microsoft.Office.Interop.Word.Shape textBox = WordApp.ActiveDocument.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationVertical, 150, 10, 40, 40);
    textBox.TextFrame.TextRange.Text = HeaderText;
    WordApp.ActiveWindow.View.SeekView = WdSeekView.wdSeekMainDocument;
    If I misunderstood or anything wrong, please let me know and you can get more information from below articles.
    Office development in Visual Studio
    http://msdn.microsoft.com/en-us/office/hh133430.aspx
    Abhout: AddTextbox Method
    http://msdn.microsoft.com/en-us/library/office/aa171543(v=office.11).aspx
    How to: Programmatically Insert Text into Word Documents
    http://msdn.microsoft.com/en-us/library/vstudio/6b9478cs.aspx

  • How to position text in an existing PDF document with X,Y coordinates

    There used to be a CFX PDF tag that could do this.  the company (www.easel2.com) does not appear to exist any more.
    This is what i want to do.  I have an existing PDF file that is uploaded by a user.  I want to receive the file, then put a registration number (some text) in the lower left corner of the 2nd page (I don't know the exact x,y coordinate but I can figure that out later).
    Does anyone know how I can do this?

    Unfortunately, I can not create the PDF.  It is uploaded by the user, and I have to open the PDF, insert the text and save it.  BUT, I did find the solution in a slight roundabout way.
    1) Create an image file containing the text I need
    2) Use that image file as a watermark with 10 opacity and use the tag's x,y coordinate setting.
    Below is the code I found to work:
    <!--- Create a blank image that is 500 pixels square. --->
    <cfset myImage=ImageNew("",500,500)>
    <!--- Set the background color for the image to white. --->
    <cfset ImageSetBackgroundColor(myImage,"white")>
    <!---Clear the rectangle specified on myImage and apply the background color. --->
    <cfset ImageClearRect(myImage,0,0,500,500)>
    <!--- Turn on antialiasing. --->
    <cfset ImageSetAntialiasing(myImage)>
    <!--- Draw the text. ---> 
    <cfset attr=StructNew()>
    <cfset attr.size=50>
    <cfset attr.style="bold">
    <cfset attr.font="Verdana">
    <cfset ImageSetDrawingColor(myImage,"blue")>
    <cfset ImageDrawText(myImage,"PROOF",100,250,attr)>
    <!--- Write the text image to a file. --->
    <cfimage action="write" source="#myImage#" destination="text.tiff" overwrite ="yes">
    <!--- Use the text image as a watermark in the PDF document. --->
    <cfpdf action="addwatermark" source="c:/book/1.pdf" image="text.tiff"
        destination="watermarked.pdf" overwrite="yes">

  • How to convert text file into xml file format with and check that with DTD

    I have an text file with | seperator . I have to convert this to an xml file and check with DTD present with me..
    plz help me out

    can i get some code that how to compare the xml with dtd or just give the DTD name with an XML

  • How to set text resources avoiding automatic page update with c:set tag

    Hello everyone,
    I'm developing my web application with JDeveloper 11.1.2.3.0 in order to support two language locales (en and de). Following this guide I've performed the following steps:
    Creation of two property files (Resources.properties and Resources_de.properties) with the key-value entries;
    Modify of faces-config.xml file adding these lines:
    <locale-config>
            <default-locale>en</default-locale>
            <supported-locale>de</supported-locale>
      </locale-config>
      <resource-bundle>
          <base-name>view.Resources</base-name>
          <var>res</var>
       </resource-bundle>
    In the project properties > Resources Bundle I've checked:
    Automatically Synchronize Bundle;
    Warn about Hard-coed Translatable Strings;
    Always Prompt for Description.
    In the same place I've set the default project bundle name to view.Resources.
    In a test JSP page I've a outputText with the value #{res['HELLOWORLD']} where HELLOWORLD is the key in the property files. All works fine, and the correct string is shown based on locale browser settings.
    Anyway, when I use the "Select Text Resources..." menu in any text value choosing a value from the default property file, JDev automatically adds the following tag:
    <c:set var="customuiBundle" value="#{adfBundle['view.ViewControllerBundle']}"/>
    setting the value of the text in #{ViewControllerBundle.HELLOWORLD}.
    There is a way to avoid this behavior? Can I manage the resources in a different way? I would to choose a value from the list in order to get the res.KEY value instead of ViewControllerBundle.KEY value.
    Thanks in advance for your help.
    Manuel

    don't select from menu - go to source and write it . The problem with the tools is they have a certain way of doing things and don't think we should spend time customizing jdeveloper rather concentrate on the work in hand.

  • How to forward text to email using iPhone 4 with IO7 MY CARRIER IS ATT

    I JUST CAN,T FORWARD MESSAGE ON MY EMAIL FROM MY TEXT I HAVE IPHONE 4 WITH IO7 CARRIER ATT 
    WHEN I TAP AND HOLD HE JUST GIVE ME NEW MESSAGE BUT NO FORWARD 

    Tap any part of the text and hold until Copy/More appears.   Then you can select then forward

  • I bought the disk Photoshop CS6 extended how do I install it on an new comp with no disk drive?

    I bought Adobe Photoshop CS6 and installed the disk on my old computer. How do I install the program onto my new computer since I do not have a disk drive to put the cd into? There is nothing on the website that I can find to help me....I really enjoy the program and didnt even realize I didnt have a disk drive in this computer....(I know its something I should have known before I bought the computer....but it slipped my mind till now when I actually need it.) Thank you....Heidi

    Hi Heidi,
    Welcome to the Community!
    That's not a problem, you can certainly download the product online. Please go to http://prodesigntools.com/adobe-cs6-direct-download-links.html and download Photoshop CS6 from there.
    Remeber to follow the instructions mentioned under "Very Important section" otherwise download won't start.
    Thanks!
    Ankit

  • Effects not showing up on 3d text layer?

    hi im running into a problem were i motion tracked some 3d text into a scene, but when i add a effect like mossaic to the text nothing is showing up. the effect is on! the text remains just the same as it was before, motion tracked but regular. Am i doing something wrong or can effects only be placed on non 3d text. btw i duplicated the text, turned the 3d off and added a effect and it worked just fine.
    here is a couple gyazo pics of it for more information
    without effect:  http://gyazo.com/bea0bafb67ef1a45888d4764dc5e84dc
    with effect added ( nothing changes)  http://gyazo.com/e4cebe245fbcf9b5c956b5174ebacd42
    everything is up to date and my computer setting are way above what they need to run after effects.

    Are you using Ray-traced rendering? Did you read the warning?
    If yes, pre-compose your ray-traced 3D text layer, make the main comp Classic, do not collapse transformations and apply your filter.

  • Strange behavior when duplicating a text layer

    Hello All,
    I was following a tutorial.
    I created a text layer.  typed in the number "2012" in white
    I placed a texture in the comp.
    I used the text layer as an alpha track matte
    Then I duplicated the Text layer, and instead of the layer being named 2012 it automatically changed to 2013.
    When I look at it as Layer Name or Source Name it was the same "2013"
    So I create a new text layer and type in "0" and the layer was appropiately named 0
    But when I duplicated that layer it was named 2014
    When I duplicated any of the text Layers it was named the next sequencially higher number
    This pattern of renaming was only broken by typing in a number where the leading digit was anther value up i.e. 4329
    Then the duplicating of the text layer would start naming the with this value plus 1.
    Same thing happens if you split the text layer
    I think this is a bug or bad programming.  this can lead to unnecessary confusion if you working on a project with number text layers and have to duplicate, many of them or many times.  Or is the answer to pre compose the text layer before duplicating --- NO that has its own shotcomings.
    CS5.5 on a Mac Os 10.6.8

    I found a solution.   Rename the Text layer by adding a space before or after the numerals.  Now the duplicates are named as the written text with a suffix  increased by 1 for each additional duplicated layer.

  • How to fit frame to content when content contains anchored text box?

    Hi there
    I am creating a series of inline text frames within a text frame. Each of these inline frames contains text which includes an anchored text frame. If I tell my inline frames to fit to content they seem to ignore the anchored frames contained therein. Is there any way I can get them to consider the anchored frames they contain when they fit to content?
    I tried checking the geometric bounds of my anchored frame before and after its parent frame has fitted to content. Even when there has been no change in position the bounds after fitting to content seem to give numbers way off. I thought I might be able to reset the geometric bounds of the containing frame manually if the anchored frame therein had moved with the fit frame to content.
    Here is a snippet of my code:
    var anchoredBounds = anchoredFrame.geometricBounds;
    mainFrame.fit(FitOptions.FRAME_TO_CONTENT);
    mainFrame.texts.item(0).recompose;
    var newAnchoredBounds = anchoredFrame.geometricBounds;
    alert(anchoredBounds[0] + "; " + newAnchoredBounds[0]);
    So “mainFrame” is the text frame containing text and the anchored frame, “anchoredFrame”. “anchoredBounds[0]” seems to correlate with the top edge of the frame when I check it manually after the script has finished (when it hasn’t move with the fit to content). “newAnchorBounds[0]”, however, always gives numbers that are way off every time. Any ideas why this would be the case?
    And most importantly, can anyone suggest how I can get my “mainFrame” to consider the “anchoredFrame” contained in it when it fits to content?
    I’m using CS4 on a PC. Let me know if it would help to post more code, or if I haven’t explained myself clearly enough.

    Is there any way I can get them to consider the anchored frames they contain when they fit to content?
    @Graham – as long as ALL the anchored text frames are "inline" text frames,
    mainFrame.fit(FitOptions.FRAME_TO_CONTENT);
    should work as expected or at least sort of *.
    Without calculating anything at all.
    Just tested in InDesign CS5.5 (v7.5.3).
    Could it be that CS4 will fail on that?
    Of course, you can only rely on this, if the main text frame contains any "real" text at all. Not only the  special characters representations of the "inline" text frames. In that case the fit() method will do nothing at all.
    * it's debatable, if the fit() method yields desirable output.
    It depends on your expectations.
    See the following examples:
    1. Case 1:
    Text frame before fitting:
    2. Case 1:
    After fitting with the UI command, context menu: "fit frame to contents"
    (note the gap between the last baseline of the text and the text frame; note also  the new width)
    Is that the result you would expect? I guess not.
    3. Case 1:
    After fitting  programmatically with myTextframe.fit(FitOptions.FRAME_TO_CONTENT);
    4. Case 2:
    Before fitting
    same text frame as in #1, but different height
    5. Case 2:
    After fitting with the UI command, context menu: "fit frame to contents"
    A different width than in #2 and a gap at the bottom of the text frame!
    Not the desired result, I'd say…
    6. Case 2:
    After fitting  programmatically with myTextframe.fit(FitOptions.FRAME_TO_CONTENT);
    Same result as in #3
    So with scripting we could, at least, get consistent results.
    Of course, you could get the same results in the UI, if you double-click on the bottom center control point…
    Maybe it helps, if you are showing us some screen grabs:
    1. Your starting point
    2. The desired result
    Uwe

  • How can I create a text layer

    I would like to know how  to create a text layer that I can place on any photo I choose

    You could create a watermark using fixed text or symbols.
    See if this video tutorial helps:
    https://www.youtube.com/watch?v=iH5mNvjuI10

Maybe you are looking for