Count layers within precomposed layer

Hello dear scripters.
I'm trying to count the layers within a precomposed layer.
has somebody a solution for my problem?
Thnx a lot.
:F
This is my code:
var curComp = app.project.activeItem; // this is my acive comp
var theSelection = curComp.selectedLayers; // i selected some comps
var compLayer = theSelection[0]; // compLayer is also a comp
// and here is my problem
// this doesn't return the number of layers within my compLayer
var theNumber = parseInt(compLayer.numLayers);
alert(theNumber); // returns undefined but i need an integer

Great. That works.
Thnx again for your help Dan.
:F
Here is the working code.
It takes a selection of comps in the active comp.
Enables timeremapping.
Adds a null as controller with some sliders.
And adds an expression to the timeremapping
this just works with CompItems.
It is usefull if the layers in the comps are sequenced with one frame length
// written by fabiantheblind
// http://www.the-moron.net
// with a hint by Dan E.
// http://forums.adobe.com/message/3310628#3310628
applyExpression ();
function applyExpression(){
    // begin an Undo group
    app.beginUndoGroup("apply Expressions");
    // check if a comp is active
        var curComp = app.project.activeItem;
    if (!curComp || !(curComp instanceof CompItem))
        alert("Please select a Composition.");
        return;
    // get the selection
    var theSelection = curComp.selectedLayers;
    // you could use this for a null within the workarea
    //var theController = curComp.addNull(curComp.workAreaDuration);
    // add a null object to the comp for the slider controls
    var theController = curComp.layers.addNull();
    // make a unique name for the null. dont use the date its just a reminder
    theController.name =  prompt("Enter an unique name for the controller Null Object", "control_"+ Date().toString());
    // loop thru selection
    for (var layerId = 0; layerId < theSelection.length; layerId++)
        var layer = theSelection[layerId];
        // get the number of layers within the layer
        // -1 because
        // layers start at index 1 frames start at 0 Frames
        // Thnx Dan for the word ".source."
        var theNumber = parseInt(layer.source.numLayers -1);
        // add a slider control to the null obj.
        var theSliderEffect = theController("ADBE Effect Parade").addProperty("ADBE Slider Control");
        // change the name of the slider to something usefull
        theSliderEffect.name = layer.name + "_cntrl_" + layerId;
        // this is for the timeremapping to make em all hold keyframes
        var holdInt = KeyframeInterpolationType.HOLD;
        // get the timeremapping property and enable it
        var property = layer.property("ADBE Time Remapping");
              layer.timeRemapEnabled = true;
            // set all keyframes to hold
      for (var i = 1; i <= property.numKeys; i++){
        property.setInterpolationTypeAtKey(i, holdInt, holdInt);
        // remove the last keyframe. dont need it
        property.removeKey(property.numKeys);
        // check if the property can take expressions
        // dont need it. but i need more checking
        if (!property.canSetExpression) { continue }
        // apply the expression with
        //the name of the slider
        // the name of the control null
        // and the number of layers within the comps
        property.expression = exprString(theSliderEffect.name, theController.name, theNumber);
    app.endUndoGroup();
// this function builds the expression string
function exprString(inEffName, inControllerName,inNum){
    // the name of the effect
    var theEffName =  inEffName;
    // the name of the control null obj
    var theCntrlName = inControllerName;
    // the number of layers within the timeremapped comps
    var theNumber = inNum;
    // the expr will be something like this: !!watch out german expression!! (replace "Schieberegler" with "Slider Control"):
    // this expression remaps the frame number within the comp to values from the slider
    // val = Math.floor(thisComp.layer("control").effect("MovementControl")("Schieberegler"))*thisComp .frameDuration;
    //if (Math.floor(thisComp.layer("control").effect("MovementControl")("Schieberegler")) < 0){val =0;
    //}if (Math.floor(thisComp.layer("control").effect("MovementControl")("Schieberegler")) > 3){val =3* thisComp.frameDuration;
    // build the string with the variables from the selection
    var theString = "val = Math.floor(thisComp.layer(\"" + theCntrlName + "\").effect(\"" + theEffName +"\")(\"Schieberegler\"))*thisComp.frameDuration;\n"+
    " if (Math.floor(thisComp.layer(\"" + theCntrlName + "\").effect(\""+ theEffName +"\")(\"Schieberegler\")) < 0){val =0;\n"+
    " }if (Math.floor(thisComp.layer(\"" + theCntrlName + "\").effect(\""+ theEffName +"\")(\"Schieberegler\")) > "+theNumber+"){val ="+theNumber+"* thisComp.frameDuration;\n }" ;
    // and return the string
    return theString;

Similar Messages

  • How to cycle thru blend modes within the Layer Style dialog??

    Hopefully, we all know you can use the Shift key and + or - to cycle through blend modes in the layers panel, as well as in various tools (like the Gradient tool or the Brush tool). A great way to quickly preview your blending options.
    But what about within the Layer Style dialog? This seems to the only situation where this shortcut does not work. Is there another shortcut or workaround that can be used here?
    I'm using Photoshop CS2 (on a Mac).
    Thanks,
    Doug D.

    That's a good point.
    I guess that Multiply (for Shadow) and Screen (for Glow) are really the "go to" blends for these effects, and including any other options beyond those is all just gravy.
    I'm just so addicted to using the Shift +/- shortcut and really like previewing blending changes that way... (But it would create a conflict within Bevel and Emboss, as you suggest.)

  • Why am I unable to select layers within the layout window - PSE13

    I am working on a project in expert mode. It has several layers. Randomly, I am now unable to select any of the layers within the layout window. I have tried to drag or click on or over an element and nothing happens, it keeps selecting the same element unless I select it from the layers utility on the right hand side. I have tried this with a mouse and a Wacom tablet, same result.

    Fixed by running updates, resetting preferences and rebooting. Phew!

  • No row count in the Physical layer of the Administration Tool

    Hi,
    While creating physical layer, I imported tables and set connection pool.
    After this, to verify connectivity, clicked Tools > Update All Row Counts.
    Now according to Oracle online guide,
    "when update all row counts completes, verify that the row counts are displayed in the Physical layer of the Administration Tool"
    I do not see the row counts in the Physical layer of the Administration Tool. No error message gets displayed either.
    Am I doing something wrong?
    I am new to OBIEE.
    Thanks in Advance & Regards,
    Deeba

    Hi Hammett81 ,
    I think, I have given configured connection pool correct. (following Oracle guidelines: 'In the Connection Pool dialog box, on the General tab, verify that the call interface is set to Default (OCI 10g) and change the data source name to the appropriate tnsnames.ora entry ( ORCL in this example). Please note that this is the TNS service name, not the ODBC DSN. ' )
    I tried to give ODBC DSN (SH) as call interface, which resulted in an Error dialogue, implying, previous configuration was correct.
    So, I reverted back.
    Regards,
    Deeba

  • Is the number of histogram pixels the same for each channel within each layer?

    Dear Photoshop Scripting Forum:
    I have written a script to isolate the number histogram pixels for each channel within each layer of a file.
    However, I have found some unexpected results: That, the number of pixels is the same for each channel within each layer.
    For example,
      Layer 1 has 18,979 pixels by itself, and so does each channel within it (Red, Green, and Blue)
      Layer 1, Channel Red, has 18,979 pixels
      Layer 1, Channel Green, has 18,979 pixels
      Layer 1, Channel Blue, has 18,979 pixels.
    This does not seem right to me.
    Does someone else have the same experience, or knowledge of something else?
    I am wondering if there is a bug in my script.
    If need be, I will post the script, but it's kind of long for a forum.
    Thank you.

    The following is for RGB 8bit images.
    The red historgram is an array of red values of the pixels that range from 0 to 255. Each element in the array has the number of pixels that have that red value. So for example if you had a layer that is pure red 255,0,0 all the pixels would be in the 255 element and there would be no pixels in the other elements. The red historgam still has the same number of pixels as the layer. They are just all in one histogram element( they all have the same value ).
    But even if you know that all the pixels in a layer are all in the last element(255) of the red histogram you still don't know the color of the pixels. A white pixel has a red value of 255. So does a yellow, magenta, etc pixel. If you only know the red value of a pixel the pixel could be one of over 65000 colors. Most of which would not be considerd 'red'
    It is the three channels together that detemine a pixel's color. Unless the layer is one color you can not tell the color of the pixels from looking at the histogram.
    Unless you use the color range selection then get the histogram of the selection. Even then you need to decide what color value make up 'red'

  • Copy drag within a layer

    To copy an object you can use Alt + the move tool and drag.  This creates a new layer. I want to copy objects by dragging within a layer but can't remember the shortcut!  Anyone know?
    I know if you hit Alt + Shift + Arrow an object will copy within a layer....but you can't manipulate its position as fast as you can if you were using the move tool.
    L

    Select first, then Control-Alt and drag.
    -Noel

  • Precomposed layer does not recognise opacity setting (bug)

    Hi
    I have a very simple precomposed layer comprising a single text layer with a drop shadow (layer style). However, it does not recognise the opacity setting in the main layer, even when set to 0% and the playhead is not even on the layer. If I change the opacity in the precomposed layer I can see it coming through to the main layer, but changing the opacity in the main layer does nothing.
    I have reported this to Adobe as a bug, anyone have any other ideas?
    Thanks
    Antony

    There is a fix. Apply a layer style to your pre-comp, then turn off the any styles. CR will now evaluate layer styles in your source comp and render them in the proper order.
    Why does that work? You have to understand how CR works. When you turn on Continuous Rasterization the layer type is identified before any effects or transformations take place. This is why you can scale a vector layer without problems if CR is turned on. This explains why a 3D pre-comp that contains a 2D layer will be rendered as a 2D layer.
    When you apply a Layer Style you are changing the layer type in the same way you change a layer type from 2D to 3D. If you want to have transformations applied to the layer style in the source file you need to change the layer type of the pre-comp layer to Layer Styles.

  • When i'm building dual layered dvds, the layer break is causing the dvd to skip to the beginning of the next chapter.

    when i'm building dual layered dvds, the layer break is causing the dvd to skip to the beginning of the next chapter.

    I would echo everything John just said - especially (and this is really important) that part about setting burn speeds to the minimum.
    Do not worry about doing this as IMGburn will automatically adjust upwards to the minimum burn speed actually supported by the media/burner combination.
    @danielrow.
    How are you currently setting your layer break please, and what OS are you running?
    If on a PC there is a fantastic tool called PGCEdit that is a swiss army knife and moreover something no authoring house should be without.......

  • Help! Can't hide layers within groups in Muse 2014.2

    Muse 2014.2 is not letting me hide layers that are apart of a group. Is anyone else having this issue and is there a fix?

    Sam,
    Thanks for the reply.
    I do not like that I cannot hide individual objects within a group. It is difficult to find good reason in only allowing top-level containers having this functionality. For objects that I may want to hide for later use my only option now is to delete (and lose all my work and formatting of the object) or bring the opacity down to 0% (time consuming).
    It would be great to have the option to hide each object/layer just like all the other amazing Adobe softwares!

  • Identify Layers within an Artboard

    Hello,
    Illustrator Artboards and Layers are unrelated. Is there a way to find out the layers contained within an Artboard?
    Thanks!

    No, because as you point out -- layers & artboards are unrelated
    Layers cover the entire canvas, while artboards are sections of the canvas. Nothing stops art from being on one layer but multiple (or no) artboards. So the question doesn't have a meaningful answer. Perhaps you're looking for "Is there a way to tell what art is contained within an artboard?"

  • Comment Forms? Layers within Tables? Crazy Idea?

    Good Day Dear Folk,
    I have designed a webpage using tables. I want to be able to
    put text in the table with the ability for viewers to scroll within
    the table. Layers have the option for scrolling text, correct? So I
    would like to put a layer in the table. I like using a table to
    center the content of the page. Is there a better way? Also, my
    friend wants visitors to be able to sign up for a newsletter and
    have the ability to leave comments about the site. I know this
    involves forms but I don't know about script writing. I'm more
    concerned about the comment form. She would like the comments to
    post directly to the page. Any ideas? Please help if you can.
    Thanks.

    > i converted my tables to layers and now it's like a
    whole new world.
    This could be equivalent to leaping from the frying pan into
    the volcano. I
    never recommended that you do that. Using Layers as a layout
    method is a
    very bad practice in general.
    1. ... any ideas?
    Are these PNG files NATIVE FW PNG files? Or did you export
    from FW as 8bit
    (or 32bit) PNG files? Try using GIF/JPG images instead.
    > 2. i want to create a page where people can leave a
    comment about the
    > website. i would like the comment to post automatically.
    i'm not sure
    > how
    > involved this is but if you can direct me to what i need
    to do, i would
    > appreciate it. if there is a high learning curve, it's
    ok. i want to
    > learn.
    > am i crazy?
    Crazy? No. It's needs like this that drive you to learn. Such
    a
    capability would require server-side scripting and database
    access. You can
    try some 'canned' approaches by Googling for 'guestbook' and
    see what you
    find....
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Itiyopiya Ewart" <[email protected]> wrote
    in message
    news:[email protected]...
    > thanks ACE!
    > i converted my tables to layers and now it's like a
    whole new world.
    > thank
    > you thank you!!! i'm learning css now... i have some
    more questions that
    > i
    > hope you can help me with:
    > 1. i'm using dreamweaver 8. i'm using OSX. my browsers
    for checking my
    > pages are safari, firefox, and opera. for some reason
    certain images
    > won't
    > show in firefox and opera. i can see them in safari, but
    the other two
    > only
    > show the alt image info. this also happens in IE. the
    files are .png.
    > they
    > were all created in photoshop from the same .psd but two
    images for the
    > navigation menu don't show. any ideas?
    >
    > 2. i want to create a page where people can leave a
    comment about the
    > website. i would like the comment to post automatically.
    i'm not sure
    > how
    > involved this is but if you can direct me to what i need
    to do, i would
    > appreciate it. if there is a high learning curve, it's
    ok. i want to
    > learn.
    > am i crazy?
    >
    > thanks!
    >

  • Saving layers within a folder to separate pdf's (complete n00bie warning)

    I have designed a set of wedding invites recently and when it came time to export I was wanting to find a smarter (and hopefully faster) way to export each individual invite.
    I have the document setup so one folder is all the artwork including details text on the card, and the second folder is a large number of text layers with each invitees name on an individual layer.
    I was wanting a script that with one click would export the first folder (with all the wording and artwork) and then only one layer out of the second (invitee text layer) folder, then repeat the process but with the next invitee name. It would be preffered if the pdf was then named after that layer name (ie: the invitee's name).
    After much searching I found this excellent script:
    Creating Multi-Page PDF from a Layerd Illustrator file (script)
    but unfortunately I couldn't find a way to make it work with only layers in one folder and leaving another folder visible.
    I am on a Mac and using CS5.
    Thanks for taking a look at my question!

    If you doc was something like this where I would expect you guest names to be sat in a layer above the base art?
    Then this should be close… Well it worked for me with this example file…
    #target illustrator
    var docRef = app.activeDocument;
    with (docRef) {
         var docName = baseName(name)
         var pdfOptions = new PDFSaveOptions();
         pdfOptions.pDFPreset = '[High Quality Print]';
         // Turn all first layers text frames off
         for (var i = 0; i < layers[0].textFrames.length; i++) {          
              layers[0].textFrames[i].hidden = true;
         redraw();
         // Turn each first layers text frames off
         for (var i = 0; i < layers[0].textFrames.length; i++) {
              if (i == 0) {
                   layers[0].textFrames[i].hidden = false;
                   redraw();
                   var guestName = layers[0].textFrames[i].contents;
                   var saveAsPath = new File('~/Desktop/' + docName + '_' + guestName + '.pdf')
                   saveAs(saveAsPath, pdfOptions);
              } else {
                   layers[0].textFrames[i-1].hidden = true;
                   layers[0].textFrames[i].hidden = false;
                   redraw();
                   var guestName = layers[0].textFrames[i].contents;
                   var saveAsPath = new File('~/Desktop/' + docName + '_' + guestName + '.pdf')
                   saveAs(saveAsPath, pdfOptions);
         //close(SaveOptions.DONOTSAVECHANGES);
    function baseName(fileName) {
         var nameString = '';
         var extOffset = fileName.lastIndexOf('.');
         if (extOffset == -1) {
              nameString = fileName;
         } else {
              nameString = fileName.substr(0, extOffset);
         return nameString;

  • How do I count numbers within a specific range in a column?

    I'm creating a spreadsheet for my college courses where I enter each score from each class as I get them back and it continues to recalculate my grades in each course.  Now I'm on the part where I want to make a box that calculates the current GPA for the semester.  I know how I'm going to do it already but I need to figure one thing out first.  Say my scores are as follows:
    85.50%
    82.00%
    92.35%
    94.25%
    78.00%
    I need a working code that counts the amount of scores within a certain range, say for example, tell me how many scores are between 80.00 and 89.99.  I can figure out how many are above/below a certain value (80.00 again for example) with a code like this [scores being the column with the grades]:
    =COUNTIF(Scores,">=80.00") ---- this gives me "4" correctly
    BUT when I add another value and want it to limit scores to not just being equal to/above 80.00 but also below 90.00 it freaks out.  I tried the two following codes:
    =COUNTIF(Scores,">=80.00","<90.00")
    =COUNTIF(Scores,">=80.00",Scores,"<90.00")
    Neither work, i'm sure i'm just wording it wrong.  It should obviously spit out the number "2" with there being two B's.  Any help would be appreciated!

    Jeremy.Osborne wrote:
    I have set up a chart just like yours with the intervals (60-100) on the left and on the right I have no idea what to do.  Do I enter that code into each box? Right now it looks like:
    =INDEX(FREQUENCY(Scores, I have no idea what to put here)
    Jeremy,
    in my response, I gave you the expression I used to build the frequency table. It was:
    =INDEX(FREQUENCY(Data :: A,A),ROW()-1)
    If you build a document exactly as the one I illustrated, the same expression will work for you. If you use a different table name, you will have to adjust the reference.
    Regarding the COUNTIFS function, you must read carefully the syntax defined in the Function Browser or the Formulas and Functions user guide and follow it to the letter.
    Jerry

  • How to reverse a PSD file that's combined layers into one layer...

    Hi,
    I'm not quite sure what happened but I had a PSD file I was working on with multiple layers and then I saved a PDF of the file and I think I may of accidentally switched up the files somehow because now my PSD file's layers are all combined into one background layer. How do I undo this (somehow release all of the layers again into the file)? I need to send the PSD file with all of it's layers available for editing and I have no idea how to fix this.
    Any help is greatly appreciated. Thanks so much!
    ashmic19

    Unless you have a backup copy of the layered PSD, you can't. Once flattened and saved, you can never reconstruct the flattened layers, they are gone. Sorry...best is to save multiple copies so if this happens in the future you won't suffer this again.

  • How do I select everything within a layer?

    I want a selection around everything in a layer. It used to be Ctrl + click on the layer name, in previous versions.

    Ctrl (Command) click directly on the layer thumbnail in the layers panel

Maybe you are looking for