[AS] Script Label Items in a Group

Hi all,
I have a group of shapes that, when grouped together in Indesign, form an object.  This grouped object is script labeled "special".  I am trying to script label each of the individual parts of this grouped object "special" so that if users ever mistakenly ungroup the object, I can still manipulate all items with the "special" label...which is effectively my original grouped object.
The catch is that I need to do this labeling with a script because I have thousands and thousands of files I'm working with.  I'd love it if something like this worked (but it doesn't):
tell application "Adobe InDesign CS3"
set theObject to page item "special" of document 1
set theShapes to every page item of all page items of theObject
set label of theShapes to "special"
end tell
The problem I keep running into is that it seems when an object is grouped, all the objects inside that group become, for all practical purposes, invisible.  The line "set theshapes to every page item of all page items of theObject" returns an empty list "{ }" as though there ARE no items making up the group.
So then I thought I'd take a more tactile approach.  Select it, ungroup it, label it, group it back:
tell application "Adobe InDesign CS3"
set theObject to page item "special" of document 1
select theObject
ungroup selection
set label of selection to "special"
group selection
end tell
The problem with this approach is that after ungrouping the object with a script, there is no longer a selection as there is when doing the same by hand, so trying to set the label of a selection that does not exist produces an error.  Grrrrr.
Friends, I know this can be done, but I need a little outside perspective on this to help me figure this one out.  As always, thanks in advance for your help!

OK. Got it working but I'm not sure why. I went back to the bigger script of which the below is a part. And it works fine. I just don't understand why.
tell application "Adobe InDesign CS4"
     activate
     set myDocument to active document
     set myPage to page pageNum of myDocument
     set active page of layout window 1 to myPage
     if not (exists library "Logowear_Lib.indl") then
          set theFile to open tagsLib
     end if
     set assetPlacer to item 1 of (place asset asset "3_12:13" of library "Logowear_Lib.indl" on myDocument)
     move assetPlacer to myPage
     move assetPlacer to myCoordinates
     set color_code_counter to 5
     set color_box_counter to 1
     tell myDocument
          repeat color_counter times
               set theColorCode to item color_code_counter of Style_List
               set oldLabelName to ("CW" & color_box_counter)
               set newLabelName to my makeImageName(theSap, theColorCode)
               set label of (object reference of every item of all page items of page pageNum of myDocument whose label = oldLabelName) to newLabelName
               set color_code_counter to (color_code_counter + 2)
               set color_box_counter to (color_box_counter + 1)
          end repeat
     end tell
end tell

Similar Messages

  • Listing of script labels items in an array

    hi,
    i use this cript to list my selection and i want to put all this labal and ID in array.
    if a create a array i dont know how put length of array because depend of documents and how many labels there are.
    thanks........ :-(
    function(){
            var p = [];
            for(var i = 0; i < app.selection.length; i++)
                p.push("Object: " + app.selection[i].toSource() + " | Contents: " + app.selection[i].label)
            return p;
        }().join('\r'), "Adobe InDesign ver. (" + app.version + ")"

    hi,
    i use this cript to list my selection and i want to put all this labal and ID in array.
    if a create a array i dont know how put length of array because depend of documents and how many labels there are.
    thanks........ :-(
    function(){
            var p = [];
            for(var i = 0; i < app.selection.length; i++)
                p.push("Object: " + app.selection[i].toSource() + " | Contents: " + app.selection[i].label)
            return p;
        }().join('\r'), "Adobe InDesign ver. (" + app.version + ")"

  • [CS3 JS] Getting a page item by its script label

    I have a text frame on a master page with its script label set. In my script, I am trying to get a reference to the text frame with this:
    var doc = app.activeDocument;
    var spread = doc.masterSpreads[0];
    var tabFrame = spread.allPageItems.item("TabLeft");
    I get the error "spread.allPageItems.item is not a function"
    Any help will be appreciated. Thanks.
    Rick

    Hi Rick,
    spread.allPageItems returns a flattened array of all of the page items in the spread, at any level of the hierarchy (i.e., inside groups and other page items). Is that what you want? Sadly, allPageItems does not benefit from the special case where we use the label as a name, so you'll have to iterate if that's what you want.
    As Peter says (thanks, Peter!), spread.pageItems.item("label") gives you all of the page items whose label matches the string, but it does so in sort of a weird way--you'll always get a page item object. If no page items match, you get an invalid page item; if one matched, you get a single page item, and if multiple page items matched, you get a page item object that actually contains multiple page items. It can take a little testing to figure out exactly what it is that was returned.
    Thanks,
    Ole

  • Listing (for further action) all page items that have a certain script label

    hello from France,
    Well the question is essentially in the subject line: how to find and work on all page items of a document (or a page/spread) that have the same script label (or better: whose script label contain the same word)?
    I tried some variations around something like that, with no results:
    set list_pageitems to every page item of page i whose label is "product"
    Any clues?
    Thanks for your help
    Vincent

    I found the answer (for those who might be interested), but still have a question (for those who know).
    The solution:
    set list_pageitems to page item "product" of page i
    If you want to do it for a whose document (in may case, deleting some page items):
    delete page item "product" of document 1
    Strange syntax but it works :-)
    The remaining question:
    How to find page items whose label contains a certain string: it would be like selecting page items by tags (every word of the script label would be considered as a tag)?
    Thanks

  • How to enable the script label of a text frames in indesign using applescript

    hi all,
    am using Indesign CS2 with applescript..
    Using script I have to open a template in indesign and flow the word document into it...
    I can able to flow the word document into the template using "Place" command..but script labels of the text frames gets disabled...
    I need the script labels to be enabled...
    can anybody help me
    thanks in advance

    Script labels can't be disabled, so I'm not sure what your problem is -- perhaps seeing some code could help. Could it be that you're referencing a page item by label, but it is not responding because the item is part of a group?
    Shane Stanley <[email protected]>
    AppleScript Pro Sessions <http://scriptingmatters.com/aspro>

  • View all script labels and find an object by its script label

    Hello,
    I have an InDesign document in which many objects get a script label. I know how to view and edit the script label of an object, but is it possible to:
    1 - See a list of all the script labels of the document (as can be done with the styles for example)?
    2 - Search an object in the document by its script label?

    If you are using OSX this AppleScript displays a list of document labels:
    global labels
    set labels to []
    tell application "Adobe InDesign CS6"
        set x to every page item of active document
        repeat with i in x
            if class of i is group then
                my checkGroup(i)
            else
                my getLabel(i)
            end if
        end repeat
        display dialog labels as string
    end tell
    on checkGroup(g)
        tell application "Adobe InDesign CS6"
            set gi to all page items of g
            repeat with a in gi
                if class of a is group then
                    my checkGroup(a)
                else
                    my getLabel(a)
                end if
            end repeat
        end tell
    end checkGroup
    on getLabel(pageitem)
        tell application "Adobe InDesign CS6"
            if label of pageitem is not "" and label of pageitem is not in labels then
                set labels to labels & label of pageitem
            end if
        end tell
    end getLabel

  • How can I get a number of items from a group

    I'm trying to load assets into a library. Most of the assets are groups. I'd like to label each asset with number of items from that specific group.
    Here is my code:
    var d=app.activeDocument;
    //create empty library
    var library = app.libraries.add(File('mylibrary.indl'));
    for(myCounter = 0; myCounter < d.pages.length; myCounter ++){
        if(d.pages[myCounter].groups.length > 0){
             //how do I get number of items from a group?
             var item_count = ?????
        }else{
             var item_count = '1';
        library.store(d.pages[myCounter].allPageItems);
        library.assets[0].name=item_count;
    Thanks for your help and Happy New Year!!!

    I figured it out!!!
    Here is the solve that worked for me:
    var elems = d.pages[myCounter].groups[0].pageItems.everyItem().getElements();
    var item_count = elems.length;

  • Ungroup a group and keep the scriptlabel for each item of the group

    Hi
    does someone know how to ungroup a group of rectangles with a certain label (example groupA) an give each rectangle a own label (the same text groupA)
    I can find the group and ungroup it but I can't label the rectangles...
    var oPageItems = app.activeDocument.allPageItems;
    for (var j = oPageItems.length-1;  j >= 0; j--) {if (oPageItems[j].label==("groupA")) {oPageItems[j].ungroup();)
    Please help

    Hi,
    before
    oPageItems[j].ungroup();
    go into the loop and set proper label to each item inside group:
    for (var k; k < oPageItems[j].length; k++)
    oPageItems[j][k].label = "groupA";
    assuming your oPageItems[j] is a group indeed.
    hope...

  • Find script label on object inside of another object.

    I have a graphic inside of a box the graphic has a script label. I would like to reference it and its parent but.
    var myAsset=myDocument.pageItems.item("Logo"); does not work. I am wondering if using allPageItems might work however, I have not made anything that has worked yet. Like var myAsset=myDocument.allPageItems.PageItem("Logo"); If there are any ideas about this I would appreciate the help.

    Hi Gonterman,
    Can you please try this JS Code.
    This code is select the page Items of "Logo"
    var myDoc = app.activeDocument;
    for (i=0; i<myDoc.spreads.length; i++){
         try{
              myDoc.spreads[i].pageItems.item("Logo").select();
              }catch(e){};
    This code is select the Graphics frome of "Logo"
    var myDoc = app.activeDocument;
    var myGrapic = myDoc.allGraphics;
    for (i=0; i<myGrapic.length; i++){
         var myArt = myGrapic[i];
         try{
              alert(myArt);
              if(myArt.label=="Logo"){
                   app.select(myArt);
              }catch(e){};
    thx
    csm_phil

  • Script Label

    Hi All,
    For my requirement i want to get a list of all page items with "id" value  in script label.
    Script Label concept in entirely new for me.
    Below script get the ID value of every page items in the active document.
    But i dont know how to save all the values [alert(("ID:" + myPgItems) in the script label.
    Trying script:
    var myDoc = app.activeDocument
    var myPageItems = myDoc.allPageItems
    alert(myPageItems.length)
    for(i=0; i<myPageItems.length; i++)
        var myPgItems = myPageItems[i].id
        alert("ID: " + myPgItems)
    Please find the attachment for more information
    Kindly give solution as soon.
    Thanks in advance
    BEGINNER

    Hi Marc/All,
    I  want to get master spreads pageitems  as well.
    But the given script get pageitems from spreads not from Master Spreads.
    function createList(/*PageItem[]*/a)
        var i = a.length,
            r = {};
        while( i-- ){ r['_'+a[i].id]=null; }
        return r;
    function compareList(o1, o2)
        var k, a=[], z=0;
        for( k in o1 )
            if( o2.hasOwnProperty(k) ) continue;
            a[z++] = k.substr(1); // as k is in the form '_id'
        return a;
    function showReport(oldList, newList)
        var r = [],
            a;
        r[0] = (a=compareList(newList, oldList)).length ?
            ("NEW ids: " + a.join(" | ")) :
            ("No NEW item.");
        r[1] = (a=compareList(oldList, newList)).length ?
            ("REMOVED ids: " + a.join(" | ")) :
            ("No REMOVED item.");
        alert( r.join("\r") );
    // MAIN
    var doc = app.activeDocument,
        s = doc.label,
        oldList = s && (new Function('return '+s)()),
        newList = createList(doc.allPageItems);
    if( oldList ) showReport(oldList,newList);
    doc.label = newList.toSource();
    alert( "Data properly saved." );
    Please can anyone help me.
    Thanks in advance
    BEGINNER

  • CS3 Script Label not found

    Hi all,
    Very much a newbie with InDesign Scripting, but I've managed to build a script that does exactly what I want - almost.
    It opens a document, looks for a Script Label, and when it's found, it does something with the item's contents. The only problem is that some of the documents don't have a Script Label, and should therefore be ignored. I've taken this code from one of the supplied examples:
    var myPageItems = myPage.pageItems.item("myScriptLabel");
    var myString = myPageItems.contents;
    If there are no items called "myScriptLabel", the second line will generate an error. How do I test whether the myPageItems actually contains any pageItems? I've tried all the obvious things I can think of, but have had no success. I'm sure the answer has to be a simple one.
    Thanks,
    Bruce

    Hi Bruce,
    Hm. I thought that this would return an array, but it doesn't--it returns a single page item, even if a.) there are no objects with that label, b.) there is one object with that label, and c.) there are multiple objects with that label. If all you want to do is set some property of all of the returned page items, this is a good thing. But if you want to do something else, it makes it more difficult. Here's a basic script that shows how to deal with it. It's probably quicker than looping through every page item.
    var myDocument = app.documents.add();
    var myRectangle = myDocument.pages.item(0).rectangles.add({label:"myLabel"});
    var myRectangle = myDocument.pages.item(0).rectangles.add({label:"myLabel"});
    var myObjectList = myDocument.pages.item(0).pageItems.item("myLabel");
    try{
    //If the object is not valid, the following line will throw an error.
    switch(myObjectList.id.constructor.name){
      case("Number"):
       //Do something with the object.
       alert("Object ID is: " + myObjectList.id);
       break;
      case("Array"):
       //Do something with each object (you can use objectByID to get a
       //reference to each object).
       for(var myCounter = 0; myCounter < myObjectList.id.length; myCounter++){
        alert("Object ID is: " + myObjectList.id[myCounter]);
       break;
    catch(myError){alert("eh")}
    Thanks,
    Ole

  • Illustrator Script Labels?

    I've done a lot of scripting in InDesign and made quite a bit of use out of nearly everything's script label. Now I'm working on a template-oriented Illustrator project that will require I store information about each layer somewhere in the file... just a 1 or 2 word description that would have fit nicely in a script label. However, I discovered there are no script labels. Does anyone have a suggestion how I might store information in an .ai file that can be retrieved later by a different script? At the very least I want to be able to store the name of one of the root layers as the primary layer (position won't help in identifying the primary label). I looked into keywords and xmpdata, but I haven't been able to get it to store anything and I'm not quite sure it's going to be much help.
    Thanks,
    Ben

    Ben:
    You can name items in AI and refer to them in a script.
    If you're on a Mac using Applescript you could do something like:
    make new ellipse at beginning with properties {name:"BensCircle",}
    then to call it you could use:
    set selection to page item "BensCircle"
    Also, if you bring up your Attributes palette, hit the flyout and there is an option to "Show Note". You can store notes about objects in it (but it doesn't work on Layers as you might hope). The Notes are also accessible to scripting.
    Hope this helps (somehow).

  • Script labels and findchangebylist.jsx

    I am looking for any examples of a script that finds a certain script label on a textframe and then runs findchangebylist.jsx on that textframe.

    Hi,
    What you need is
    1. to simplify function
    main()
    2. and to modify:
    myFindChangeByList(myObject)
    myDisplayDialog()
    Ad 1.
    function main(){
        var myObject;
        //Make certain that user interaction (display of dialogs, etc.) is turned on.
        app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
        if(app.documents.length > 0) myDisplayDialog();
        else alert("No documents are open. Please open a document and try again.");
    Ad 2
    function myFindChangeByList(myObject){
        var myScriptFileName, myFindChangeFile, myFindChangeFileName, myScriptFile, myResult;
        var myFindChangeArray, myFindPreferences, myChangePreferences, myFindLimit, myStory;
        var myStartCharacter, myEndCharacter;
        var myFindChangeFile = myFindFile("/FindChangeSupport/FindChangeList.txt")
        if(myFindChangeFile != null){
            myFindChangeFile = File(myFindChangeFile);
            var myResult = myFindChangeFile.open("r", undefined, undefined);
            if(myResult == true){
                //Loop through the find/change operations.
                do{
                    myLine = myFindChangeFile.readln();
                    //Ignore comment lines and blank lines.
                    if((myLine.substring(0,4)=="text")||(myLine.substring(0,4)=="grep")||(myLine.substring(0,5)=="glyph")){
                        myFindChangeArray = myLine.split("\t");
                        //The first field in the line is the findType string.
                        myFindType = myFindChangeArray[0];
                        //The second field in the line is the FindPreferences string.
                        myFindPreferences = myFindChangeArray[1];
                        //The second field in the line is the ChangePreferences string.
                        myChangePreferences = myFindChangeArray[2];
                        //The fourth field is the range--used only by text find/change.
                        myFindChangeOptions = myFindChangeArray[3];
                        switch(myFindType){
                            case "text":
                                if (myObject instanceof Array)
                                    for (var k = myObject.length - 1; k >=0; k--)
                                    myFindText(myObject[k], myFindPreferences, myChangePreferences, myFindChangeOptions);
                                else myFindText(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
                                break;
                            case "grep":
                                if (myObject instanceof Array)
                                    for (var k = myObject.length - 1; k >=0; k--)
                                    myFindGrep(myObject[k], myFindPreferences, myChangePreferences, myFindChangeOptions);
                                else myFindGrep(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
                                break;
                            case "glyph":
                                if (myObject instanceof Array)
                                    for (var k = myObject.length - 1; k >=0; k--)
                                    myFindGlyph(myObject[k], myFindPreferences, myChangePreferences, myFindChangeOptions);
                                else myFindGlyph(myObject, myFindPreferences, myChangePreferences, myFindChangeOptions);
                                break;
                } while(myFindChangeFile.eof == false);
                myFindChangeFile.close();
    function myDisplayDialog(){
        var myObject, mFramesLabels, mFrames = [];
        var myDialog = app.dialogs.add({name:"FindChangeByList"});
        with(myDialog.dialogColumns.add()){
            with(dialogRows.add()){
                with(dialogColumns.add()){
                    staticTexts.add({staticLabel:"Search Range:"});
                var myRangeButtons = radiobuttonGroups.add();
                with(myRangeButtons){
                    radiobuttonControls.add({staticLabel:"Document", checkedState:true});
                    radiobuttonControls.add({staticLabel:"Selected Story"});
                    radiobuttonControls.add({staticLabel:"Labeled Frames"});
                    if(app.selection[0] && app.selection[0].hasOwnProperty ("baselineShift") && app.selection[0].contents != ""){
                        radiobuttonControls.add({staticLabel:"Selection", checkedState:true});
        var myLabel = textEditboxes.add({staticLabel:"Label:", minWidth: 185});
        var myResult = myDialog.show();
        if(myResult == true){
            switch(myRangeButtons.selectedButton){
                case 0:
                    myObject = app.documents.item(0);
                    break;
                case 1:
                    myObject = app.selection[0].parentStory;
                    break;
                case 2:
                    mFramesLabels = app.documents.item(0).textFrames.everyItem().label;
                    for (var k = 0; k < mFramesLabels.length; k++)
                        if(mFramesLabels[k].length && mFramesLabels[k] == myLabel.editContents)
                        mFrames.push(app.documents.item(0).textFrames[k]);
                    myObject = mFrames;
                    break;
                case 3:
                    myObject = app.selection[0];
                    break;
            myDialog.destroy();
            myFindChangeByList(myObject);
        else{
            myDialog.destroy();
    Make a copy with mentioned function replaced with.
    Enjoy
    Jarek

  • Is there any way to select Worklist items by BP grouping?

    Hi All,
    Our client now needs to select worklist items by BP groups, that is, we would need another selection option in this window:
    I highlight that we don´t need to change neither Segments nor Collection Groups, just to group certain customers so that they could be jointly selected when viewing the Worklist.
    The option we are trying to use is the functionality availbale at BP Master data:
    However, we are not sure if BP Groups can be selected when trying trying to see the Worklist items (first image).
    Is it possible to add new selection fields on that Display Worklists window? How?
    Does anyone have an idea in order to group a little number of BP so that they can be displayed at the Worklist by its selection?
    Many thanks in advance

    Hi Wilson,
    Its not the Group Icon that you highlighted which is used to group BPs. It is the BUT000-BU_GROUP field. You define the Groups in configuration and while creation of BP you select one. And then as per the logic given by Florent use the BADI UDM_WL_ITEM_DISP_C to populate this field in Worklist and filter based on this field.
    Regards
    Prateek.

  • Script Label insert into FileName

    Any help would be greatly appreciated!
    This is a portion of "PageExporterUtility5.0.js" that I'm tailoring to use at our workplace. Finding a simple description of how to use the "Script Label" is stumping me. How would you modify the following to work? My InDesign document has a Text Frame that I'd like to utilize the text contents in the filename. The text frame has been identified with a "Script Label" called "DOC_SIZE". An example of the text contents would be "18X24" (which is not the actual page size, just a rough description is needed).
    Current Base Name:
    816069-OHI-none-none.indd
    Export Name:
    816069_18X24_"Output Directory".eps
    w/ the Output Directory, I'd like to use the Folder Name, not the full path.
    These are the revalent sections of the script identifying the "outFile" Name.
    VAR SETUP
    for(currentDoc = 0; currentDoc < peuINFO.numDocsToExport; currentDoc++) {
        var tempENTRY = getNewTempENTRY();
        tempENTRY.theDoc = app.documents[currentDoc]
        tempENTRY.singlePage = (tempENTRY.theDoc.documentPreferences.pagesPerDocument==1)?true:false;
        tempENTRY.getOut = true;
        var baseName = (tempENTRY.theDoc.name.split(".ind"))[0];   
        var baseName = baseName.replace(/-OHI-none-none/g, "")
    MIDDLE
        else{
                currentINFO.outfileName = currentINFO.baseName;
                exportPage(currentINFO, PageRange.allPages);
    EXPORT PORTION
        case 2:
                app.epsExportPreferences.pageRange = pgRange;
                    currentINFO.theDoc.exportFile(ExportFormat.epsType, (new File(outFile + ".eps")), false);

    If the problem is getting the text contents of your labeled box, try something like this:
    var docsizeBoxes = new Array;
    for (var i = 0; i < app.activeWindow.activePage.textFrames.length; i++) {
        if (app.activeWindow.activePage.textFrames[i].label == "DOC_SIZE") {
            docsizeBoxes.push(app.activeWindow.activePage.textFrames[i]);
            break; }
    var docsizeString = app.activeWindow.activePage.textFrames[i].contents;
    You should now be able to use docsizeString in parsing out the name of the output file.  This assumes that there will be one and only one text frame labeled "DOC_SIZE" on the active page. So you might need some error checking.
    If it were me, though, I'd just get the actual pageWidth and pageHeight from documentPreferences and use them. In my place, we don't have too many doc sizes to choose from.

Maybe you are looking for

  • Problem with call identification

    Hello. I'm doing tests with a E61, E65 and E71 phones. I have the same problem. I've installed Mnotes suites for synchronize Lotus Notes mail with this phones. This is OK. I also synchronize the guide with our corporative directory of people. It's OK

  • SAP CRM to MS Access Interface

    I have a CRM to MS Access Interface that I have to set up. Has anyone set that up before and if so; How was it done? Any documentation on that?

  • Finding the archive backup or not

    How to check weather the particular archive log backup or not in Rman ?

  • NI LabVIEW Toolkit for LEGO MINDSTORMS NXT

    Labview 7.1.0と一緒に.タイトルのtool kitを使って. LEGO MINDSTORMS NXTを動かそうとしているのですが. 一括コンパイル.nxt tool kit 1.0.1 patchコピーを終え. "Getting Started with the LabVIEW toolkit for LEGO MINDSTORMS NXT"(添付) の最初の"Building a LabVIEW VI that Runs on the NXT"に従って. 作成したVIをNXT上で動

  • Crashing frequent

    why is safari,itunes,appstore and games crashing on my 32gb wifi only ipad?