detect pageitems groups and iterate through the items in each group

Hello

I can use some help with a script that I'm trying. The script creates a new layer based on a fill color of objects and then move the item to the new layer.

What I can't understand is how to check if a pageItem is a group, and if so, scroll through all the objects within the group. What I have so far (snippit) is:

var doc = app.activeDocument;
var LayerName = "0";
var MyArray = new Array;

for ( j=0; j < Counter; j++ ) 
    {
    CurrentItem = doc.pageItems[j];
    if (CurrentItem.typename != "GroupItem" && CurrentItem.typename != "CompoundPathItem" && CurrentItem.parent.typename != "GroupItem" && CurrentItem.parent.typename != "CompoundPathItem") 
       {  
        LayerName = ConstructLayerNameBasedOnFillColor( CurrentItem );
        CurrentItem.move( app.activeDocument.layers.getByName( LayerName ), ElementPlacement.PLACEATBEGINNING );
       }
      else 
       {  
        if (CurrentItem.typename == "GroupItem") //  seems to be wrong as it also returns true for an item within the group
        { 
         myArray = [];
            for ................ // cycle through each item within the group
             {
              LayerName = ConstructLayerNameBasedOnFillColor( CurrentGroupItem );
              MyArray.push(LayerName);
             }
         LayerName = GetMostCommonColor(MyArray);
         ................. // move the group (including all items within the group) to layer LayerName
          }
       } 
    }

Is the part that I need help:

1:  if (CurrentItem.typename == "GroupItem") //  seems to be wrong as it also returns true for an item within the group
2:     { 
3:     myArray = [];
4:      for ................ // cycle through each item within the group
5:         {
6:          LayerName = ConstructLayerNameBasedOnFillColor( CurrentGroupItem );
7:          MyArray.push(LayerName);
8:         }
9:     LayerName = GetMostCommonColor(MyArray);
10:     ................. // move the group (including all items within the group) to layer LayerName
11:    }

line 1: how to check if the pageItem is a group

line 4: scroll all the items in the Group

line 10: move the group to a new layer

Any help is appreciated.

Have you tried running the loop backwards in the case where the index is messed up.

 m=0; m < CurrentItem.pageItems.length-1; m-- 

Tags: Illustrator

Similar Questions

  • Iterate through the items in the cluster

    Hi all

    I have a cluster with several elements of the same type. I want one any of them handle in the same way, keeping however their labels. My solution works, however, it is prone to errors of cabling one its not really scalable. you have a better idea?

    Thank you!

    RubeGoldberg alarm!

    What is the problem with the application of the function of math on the cluster directly?

  • Iterate through the objects of the child in components

    I have a custom component named myComp that has three TextInputs. And in the main application there is a button that adds the component dynamically to the VBox named myVBox, I would like to know how iterate through the added components and display the text inside each of the TextInputs in a box of Alret. I'm pretty new to flex and I couldn't find examples for this.

    Thank you

    Code example,

    Custom component

    MyComp1.mxml

    
    http://www.adobe.com/2006/mxml">
         
         
         
    
    

    Application

    
    http://www.adobe.com/2006/mxml"
         layout="absolute"
         creationComplete="init()">
         
              
         
    
         
              
              
              
              
         
    
    

    Hope this helps you

  • Iterate through the DB using DBcursor-&gt; get with the DB_DBT_USERMEM flag set for DBT

    BDB works in mode TDS. You want to iterate over a database using a DBcursor from beginning to the end. set the flag DB_DBT_USERMEM on the structure of the DBT with data pointing to a block of memory allocated fixed size to organize content in a single record reading. Currently the cursor get fails with DB_BUFFER_SMALL. I guess that's because the cursor-> get retrieves several records.

    It is possible to iterate over the DB using the cursor said while allocating memory for only a 1 user database? Each call to cursor-> get with DB_NEXT / DB_PREV / DB_FIRST DB_LAST etc. would be updated of the unique registration entry.

    Hi Kedar,

    No, DBcursor-> get() picked up several key/data elements if you are using the DB_MULTIPLE or DB_MULTIPLE_KEY flags. See "Bulk Retrieval:
    [http://www.oracle.com/technology/documentation/berkeley-db/db/programmer_reference/am_misc_bulk.html#am_misc_bulk_get]
    You want only to retrieve a single record per call, so do not use the above indicators. In this case, the DB_BUFFER_SMALL error indicates that the length of the item requested/retrieved is greater than that specified for the DBT via his "ulen" field
    [http://www.oracle.com/technology/documentation/berkeley-db/db/api_reference/C/dbt.html#dbt_DB_DBT_USERMEM]
    If you want to iterate through all the records in the database (including duplicates, if the database is configured to support), you must use the DB_NEXT flag.
    Note that when the DB_BUFFER_SMALL error returned the field 'Size' of the DBT is on the length needed for the item requested; You can check this value to determine how the size of your buffer provided (or you can know in advance the size of the items in the database).
    Here is an excerpt of the example code to "Retrieve records with a cursor" with the necessary adjustments for the TCD data:
    [http://www.oracle.com/technology/documentation/berkeley-db/db/programmer_reference/am_cursor.html#am_curget]

         DB *dbp;
         DBC *dbcp;
         DBT key, data;
         int close_db, close_dbc, ret;
    
         //...
    
         /* Acquire a cursor for the database. */
         if ((ret = dbp->cursor(dbp, NULL, &dbcp, 0)) != 0) {
              dbp->err(dbp, ret, "DB->cursor");
              goto err;
         }
         close_dbc = 1;
    
         /* Initialize the key/data return pair. */
         memset(&key, 0, sizeof(key));
         memset(&data, 0, sizeof(data));
    
         /* Retrieve data item in user suplied buffer. */
    #define BUFFER_LENGTH 1024
         if ((data.data = malloc(BUFFER_LENGTH)) == NULL)
              return (errno);
         data.ulen = BUFFER_LENGTH;
         data.flags = DB_DBT_USERMEM;
    
         /* You can supply your own buffer for the key as well. */
    
         /* Iterate through the database. */
         while ((ret = dbcp->c_get(dbcp, &key, &data, DB_NEXT)) == 0)
              /* Operate on the retrieved items. */
         if (ret != DB_NOTFOUND) {
              dbp->err(dbp, ret, "DBcursor->get");
              goto err;
         }
    
    err:
         // ...
    

    Kind regards
    Andrei

  • locking and unlocking through the command, 'cacls' locked but not unlock

    Dear Firend I tried locking and unlocking through the command, "" D:\Murali/e/p everyone cacls: n ' "

    afterwards, while liberating, he said like that

    C:\Documents and Settings\yantra > cacls d:/Murali /e /c /p yantra:F
    ACCESS_DENIED: d:\Murali

    Please someone help me

    Hello

    The question you posted would be better suited in the TechNet Forums. I would recommend posting your query in the TechNet Forums:

    http://social.technet.Microsoft.com/forums/en/category/windowsxpitpro

  • What is the difference between the element catalog and category of the item

    What is the difference between the element catalog and category of the item

    PL. visit the following links.

    Point Catlog

    Catalogue of objects: Oracle ERP Apps Guide

    What is the difference between the category of the item and itemcatalog you can plea

  • I bought Photoshop CS2 in 2005. I recently changed my PC and load the software on the new PC.  I load the CD and proceed through the steps.  When it's time to serial number software tells me the serial number on the CD case is not valid

    I bought Photoshop CS2 in 2005. I recently changed my PC and load the software on the new PC.  I load the CD and proceed through the steps.  When it's time to serial number software tells me the serial number on the CD case is invalid.  It is the same serial number, I used previously.  How do I remedy this situation so that I can use the software on my new pc?

    First, use the serial number to the right of the download for Windows.

    Do not place information in the field of the Organization after you enter the number. Which causes problems.

    If you have windows 8, you may need to change the directory to progra ~ 2 on some 64-bit windows systems:

    The reason for the use of progra ~ 2 on a 64-bit system when installing a 32-bit application is the 8 character limit imposed by Windows. PROGRA ~ 2 totals up to 8 characters, program ~ 2 is 9

    You have 2 options:

    1. in the installation, change your path to C:\progra~2\... and install it. It should work.

    2 copy Setup on your local drive. The right click on Setup.exe, properties > Compatibility tab > run in compatibility mode. The choice of XP SP2. Click OK. Run Setup.exe

    Either we have to work.

  • Trying to cancel my subscription but can continue to will return to bike and returns through the cancellation process - tells me I need to call customer service but no phone number is available.

    Trying to cancel my subscription but can continue to will return to bike and returns through the cancellation process - tells me I need to call customer service but no phone number is available.

    Hello Marilyn,.

    Please sign in to your Adobe account and then go to the link below:

    Contact the customer service

    Reference: cancel your creative cloud membership

    Kind regards

    Sheena

  • I can create a branch to several branches then have a quiz and evaluation at the end of each branch?

    Captivate 9

    I can create a branch to several branches then have a quiz and evaluation at the end of each branch?

    The situation: I have 10 roles taking the same training.  each will have to branch halfway through and take their own quiz.  It needs to report on completion of 80% of cornerstone LMS.

    You can take a look at a use case in this blog: branch aware Quiz - blog of Captivate

    If you can deal with limitations of navigation because of the current branch, you will see that it works very well.

  • II-think ME214 will not go start page and surveys through the process on when I touch the screen, but used to progress beyond this point

    I have a ME214 ii - think she returned to Chinese writing it starts and get to first page once I touch screen that it queries through the start-up process each time. Also when I connect to the computer it not of resistances that it is a device on the computer. He information in the manual that there is a reset on the side button but I can't find a someone out there could provide some answers please

    Hi Stanley_50,

    ·         He has already worked?

    ·         Did you do changes on the computer before the show?

    ·         What is the exact make and model of the unit?

    Run the fixit of the article.

    Hardware devices do not work or are not detected in Windows

    You can contact the manufacturer of the device to reset the key.

  • How can I prevent the shutdown task scheduler engine, get the new display detected to work and avoid receiving the message "Internet Explorer has encountered a problem and stop"? __

    My laptop is a Dell Inspiron 1520, running Windows Vista Home Edition Premium and Internet Explorer 9.  My extra monitor is a Sharp Aquos LED HD - TV, the model LC-46LE700UN.  I've been using a VGA cable to me onnecter the laptop and TV.

    The laptop seems to operate normally when not connect to the TV.

    As soon as the VGA cable is connected to the laptop (without being connected to the TV), the following message appears:

    'Microsoft Windows - Task Scheduler engine has stopped working.  A problem caused the blocking of the program works correctly.  Windows will close the program and notify you if a solution is found. »

    When initially, I connected the laptop to TV, "new display detected" was automatically acti EV.  Soon, it was activated is no longer automatically.  I was able to activate manually using Windows Mobility Center during automatic activation failed initially but now Windows Mobility Center no longer detects the new view.

    Using Fn + F8, I can view the image on the laptop or TV, but not both simultaneously.

    The message "Internet Explorer has encountered a problem and stop" appears intermittently, but I can still make internet sites and show the content after the message.

    I have download software, myp2p.eu, a site for watching TV programs "streaming", including PPStream, Sopcast, Live, Stream Torrent Sina, a Swarm, TVAnts, UUSee, VGO and Veetle player and canceled downloads for PPL (who failed an integrity check), PPMate (corrupted) and (blocked) TVKoo.

    Norton Security quarantined the installer of UUSee, indicating that it was a high risk of program with many users.

    To a computer repair shop and using a different additional display flat screen, I could not duplicate the problems yesterday (4 October 2010), when the "new detected display" has been activated automatically, and I could see the photo or the other and both screens.

    I tried to restore the system to a date (on the list) before when the problems occurred first - failure of the restoration of the system.  I tried to use scandisk, but received no indication that he had performed and corrected all errors found after restarting Windows.  I looked at responses from forum, the display setting and the new display detected support literature.

    How can I avoid these problems?  Help!

    Hello

    Restoring the system end up with any error message?

    This could also happen if one of the substantive programmes is in conflict with the proper functioning of your computer. To troubleshoot error messages and other issues,
    You can start Windows Vista by using a minimal set of drivers and startup programs. This type of boot is known as a "clean boot". A clean boot helps eliminate software conflicts.

    Steps-
    1 log on to the computer using an account with administrator rights
    2. click on start, type msconfig.exe in the start search box and press ENTER to start the System Configuration utility.
    If you are prompted for an administrator password or for confirmation, type your password, or click on continue
    3. on the general tab, click Selective startup, and then clear the check box load startup items. (The check box use the file Boot is not available.)
    4. on the Services tab, click to select the skin all the Microsoft services check box, and then click Disable all

    Note: Following this step lets services Microsoft continue to run. These services include networking, Plug-and-Play, record of events, error reporting, and other services.
    If you disable these services, you can permanently delete all restore points. Do not do this if you want to use with existing restore points system restore utility

    See this article-
    http://support.Microsoft.com/kb/929135

    This should solve your problem.

    -Robert

  • Loop through the item with variables

    OK, I have 10 textInputs which are named tiDepart1, tiDepart2, tiDepart3... The only difference of nature is the number of the TI.

    So what I want to do, it's all just have a loop on a random number of these TI and assign some properties.

    For example:

    for

    (i = 0; i < 6; i ++) {

    ddDepart + i.visible = true;

    }

    You can see the small I ask in the space where the number of technology should be. So, with this command, I managed to set them all the visible property to true.

    It is a simple and useful command that will allow me to win a lot of code if I can manage to make it work.

    Anyone have an idea on how to make this work?

    I also thought that maybe it would be necessary to put my items in a table, so I can loop through them easily.

    But is it possible to include items such as a combo box or text in an input array and still have access to their properties.

    Thank you very much and sorry for the bad English.

    Dominic

    There is nowhere you can be that isn't where you're supposed to be. -the beatles-

    for (var i: int = 0; i< 6;="" i++)="">

    This ["ddDepart" + i] .visible = true;

    }

    In general, however, yes - put the latter in a picture, or something like that would probably be a cleaner approach.

  • Damaged my iPhone 5.  Receipt of replacement and went through the steps of activation.  All transferred very well - I thought.  Now, the phone only works when connected to wifi.  Help!

    Damaged my iPhone 5.  Make an insurance claim and received a replacement.  Has passed through the stages of restore/update / back.  Everything seemed to go well.  However, I can only send/receive texts or to use the phone when connected to wifi.  Saved settings and recontroler.  Nothing works.  Help!

    Hello

    I'm sorry to hear that you are not able to use your cell phone... Well well... like a cell phone.

    I suspect the 'texts' you send and receive through iMessage, not your cellular service provider network. When you look at the top left of the screen, it does not say 'search' or does it see the connect to your provider's network?

    Have you tried the steps If you cannot connect to a cellular or cell - data Apple Support Network?

  • Help! My files sent for two whole months are missing! I have looked everywhere and looked through the forum topics, without success.

    At the beginning of a new month, Thunderbird normally creates a sent folder for the previous month, as in "Feel-Apr-2014." All my emails in the last two months are - missing files for March and April 2014. I looked through all my records, to see if they went to the wrong place. I also tried searching for individual emails by name, to see if they are elsewhere, but there is a gap of two months with no emails showing up during this time. I checked my master settings, to make sure that nothing is set to automatically delete. This is very serious. I'll have to stop using Thunderbird, I used for four years, if I can't solve this problem, because I can not afford to continue to lose huge chunks of important emails.

    Thank you. Your account appears to be IMAP, that is, all mail is handled on the server.

    Can connect you to your account via webmail and check if the mail is missing on the server?

    At the beginning of a new month, Thunderbird normally creates a sent folder for the previous month, as in "Feel-Apr-2014."

    Is it possible that this is done by the server?

    Of after troubleshooting - profile directory - Open Directory information

    Your profile folder opens in Windows Explorer. Under ImapMail, look for a folder with your domain name in the name of the folder, i.e. something like mail. [sitename] .com. What are records under?

    Maybe you can post a screenshot.

    http://support.Mozilla.org/en-us/KB/how-do-i-create-screenshot-my-problem

  • Cannot start Windows 7 message and passed through the repair. SYSKEY problems?

    I received a call that the security program, we have installed last year had been compromised. We bought this company safety program. Then they asked to get on computer, which they did. Then they showed through the event viewer that the computer has been used by others. Started sounding fishy and then they wanted to buy us another program. I told him that I wanted him out of the computer, I would call them back. The guy then pulled up the syskey and typed a password and is out. Worked very well after that but now it works and now I received a message that microsoft cannot be started. The sykey is too ride with my original to enter the computer password?

    Examine your computer to be totally compromised.  You follow the recommended procedures for identity theft.

    Do not use the computer or go online for nothing. Re-install your system or have done to you.

    Notify your banks, credit cards, the police and the post office.

    Never allow people to connect to your computer, unless you are quite comfortable, that they are worthy of trust.  You have been scammed.

Maybe you are looking for

  • NZ794EA #AB8: Hp compaq mini password Bios

    ENTER THE CURRENT PASSWORD VERIFICATION OF PASSWORD FAİLED FATAL ERROR... SYSTEM ORDER. CNU92545HM MODEL 110 C - 1020ST

  • Pavilion 15-au111tx: I don't have a virtual Wifi Mini card

    I do not have this Microsoft Virtual WiFi Miniport Adapter to start a hotspot where can I find?

  • External microphone no longer works on Satellite M40 PSM44

    HelloI have the problem with the external microphone on my satellite M40 PSM44. When I connect it do all the settings its fine for a while to work. All of a sudden it stop working. After that I had to uninstall audio drivers and install it again and

  • Photosmart 8250 colors are far

    Photosmart 8250 is a great printer for several years. (off warranty now of course) I did not have any paper or photo, 4 x 6, all power problems and had a paper jam. Lately color printing has gone wrong. I have never used a "recharging" printer uses H

  • Help customization Facebook notifications

    I just got my cliq yesterday and I love it. only thing I'm not crazy, it's that my battery was drained when I woke after recharge forever the day before. I had a ton of notifications of friends on facebook. is there anyway to choose who I want to rec