apply a clipping for each top-level group mask in the document

Sample file: https://drive.google.com/file/d/0BzEoJSYDhH_WcXhIalFRTk9qOGc/view?usp=sharing

We can assume:

Art • grouped on configurations with a line called die.

• All groups exist on "Layer 1"

I am a loop in groups and work with groups who has relatives is "layer". I have to loop through all the groups in the document, but when I created the clipping mask creates a new group and live my loop. I am now a loop only in groups of "Layer 1"and moving them to a new layer before the clipping mask. My script is breaking after the Group has been moved to the new layer. I have a bunch of alerts in there for debugging.

#target Illustrator


var idocX = app.activeDocument;
var li = idocX.layers;


function meetTheParents(PageItem){
  if (PageItem.parent.typename = "Layer"){
  return "Layer";
  } else if (PageItem.parent.typename = "GroupItem"){
  return "Group";
  } 
}

function isLayerFree(layer){
  if (layer.locked == false && layer.visible == true){
  var gpa = layer.parent;
  isLayerFree(gpa);
  return true
  } else {
  return false
  }
}


var trLyr = li.add();
trLyr.name = "TRASH";
var l1 = li.getByName('Layer 1');
for (j = l1.groupItems.length -1; j >= 0; j--) {
  app.executeMenuCommand ('deselectall');
  var iGroup = l1.groupItems[j];
  if (iGroup.hidden==false && iGroup.locked==false) {
  if (meetTheParents(iGroup) == "Layer"){
  if (isLayerFree(iGroup.parent)){
  iGroup.move(trLyr, ElementPlacement.PLACEATBEGINNING);
  // set die variable to die in current selection
  alert ("Group " + j + " moved to trash layer");
  alert ("trash layer path items length = " + trLyr.pathItems.length); // I'm getting '0' here even though I just moved items into it.
  var die = trLyr.pathItems.getByName('proofLine'); // script breaks here
  alert ("Die identified for this group");

  die.move(trLyr, ElementPlacement.PLACEATBEGINNING);
  for (a = 0; a < trLyr.pageItems.length; a++){
  var thing = trLyr.pageItems[a];
  if (thing.hidden==false && thing.locked==false){
  thing.selected = true;
  }
  }
  var sel = idocX.selection; // get selection
  alert (sel.length + " items in current selection.");

  // make clipped group of die with art inside
  if (sel.length==2) {// continue only if 2 objects are selected
  var igroup = idocX.groupItems.add(); // add a group that will be the clipping mask group

  var imask = sel[0]; // the mask is the object on top
  var ipath = sel[1]; // the "drawn object" is at the bottom

  var idup = imask.duplicate(); // duplicate the mask, to later get the fill and stroke to apply to the clipping path

  ipath.move (igroup, ElementPlacement.PLACEATBEGINNING); // add both path to the group
  imask.move (igroup, ElementPlacement.PLACEATBEGINNING);

  imask.clipping = true; // make the mask the clipping path
  igroup.clipped = true; // clip the everything in the group to the clipping mask

  if (idup.filled == true){
  imask.fillColor = idup.fillColor; // add fill color, same as the dup
  }
  imask.stroked = true; // stroke the mask
  imask.strokeWidth = idup.strokeWidth; // add stroke width, same as the dup
  imask.strokeColor = idup.strokeColor; // add stroke color, seme as the dup

  idup.remove(); // remove the duplicate
  }else { // show this message if other than 2 objects are selected
  alert("Select both, the Mask and the object that needs to be 'inside'.\rThe Mask needs to be the top most object.");
  }
  app.executeMenuCommand ('deselectall');
  igroup.move (l1, ElementPlacement.PLACEATBEGINNING);
  }
  }
  }
}
trLyr.remove();

Inside of my plu script that it breaks in silence, in this example script is for me a 'no such item. There should be such an element, I just put there. Once the script completes, the Group has been moved, which means that the named path is right where it should be.

Let's see if this works:

#target illustrator
function test(){
    if(app.documents.length < 1){
        return;
    }
    var doc = app.activeDocument;
    var lr = doc.layers[0];
    for(var i=0; i 
         

Tags: Illustrator

Similar Questions

  • JavaScript to make the selection of top level group?

    Does anyone know how to select a group of high level by index?

    For example, I have a lot of files with deeply nested groups and I want to select all the illustrations as high-level groups and create a work plan around the visible boundaries of the group.

    I was able to loop through the groupItems from the document, but I can't seem to tell the difference between the higher level groups and subgroups. In other words, the loop works properly, but it is creating a plan to work around the Group of high level and then around each sub-group and each group within this subgroup.

    In the image as an attachment, you can see that there are 5 top-level groups in this document. However, everything else is essentially grouped within these groups. for example, the logo 'Earth' is about 100 + path grouped items. information on the collar are grouped several times in a complex hierarchy as well.

    The obvious solution is to decouple everything and then regroup every piece of shirt in 1 group. Unfortunately, that in itself is a lot more time than to manually create work plans and then the file is not very clean, if never go back inside to change/fix something.

    I guess a way to loop through the subgroups and ignore them if they are in the geometric limits of higher level? But I'm not really sure where to start on this code...

    This is the code that I currently have which creates around each groupItem, work plans, but also around each groupItem in the upper level... it up also a mistake because I think that illustrator can not cope to create work plans that fast? When I run the same script on less complicated work, it works fine.

    var docRef = app.activeDocument;
    var aB = docRef.artboards;
    var gI = docRef.groupItems;
    
    
    for (a = 0; a< gI.length; a++){
        var currentGroup = gI[a];
        currentGroup.selected = true;
        var vB = currentGroup.visibleBounds;
        aB.add(vB);//an Illustrator error occurred: 1346458189 ('MRAP')
    }   
    

    any ideas how to isolate this high-level group and ignore the rest? Thank you people.

    Screen Shot 2015-01-05 at 11.06.17 AM.jpg

    Instead of document.groupItems, try document.layers [0] .groupItems

  • When using PDF documents for signature, you need to 'send' the document for signature? Alternatively, can I publish the document on my site and just ask visitors to sign without send me to each person, when using PDF documents for signature

    When using PDF documents for signature, you need to 'send' the document for signature? Or can I publish the document on my site and simply ask visitors to sign without send me to each person?

    Hello

    You can use the Widget feature to publish the document on your website. Here is the link for reference:

    https://helpx.Adobe.com/document-cloud/help/create-widgets.html

    -Usman

  • Need for each week of grouping on a date column

    Hi, I have the following query

    Select user_name 'user who accessed '.

    , count (user_name), "number of accessible times.

    of apex_workspace_access_log

    where application_id = 123

    and TRUNC (access_date) BETWEEN to_date (1 July 2013 00:00:01 "," dd-mon-yyyy hh24:mi:ss') and to_date (4 August 2013 23:59:59 ',' dd-mon-yyyy hh24:mi:ss') Group of user_name,.

    At the moment it displays the data for each day from July 1, 2013. I need to view the data in my application a week... We hear that he should consolidate the meter and the username per week.

    as from July 1 to July 7, July 8-14 July, 15 July-21 July, 22 July to 28 July, 29 July - 4 August and so on.

    Could you please let me know if we can do this via the query?

    which can be achieved by putting Manik query as a point of view online by using the function command Rank by the number of the week.

    Select user_name (user_name) count, rank() (command per week CSA) week from (SELECT user_name 'User who has consulted',

    COUNT (user_name) 'number of times accessed.

    TO_CHAR (access_Date, 'IW') week

    Of apex_workspace_access_log

    WHERE application_id = 123

    AND TRUNC (access_date) BETWEEN TO_DATE (1 July 2013 00:00:01 ',)

    "hh24:mi:ss mon-dd-yyyy")

    AND TO_DATE (4 AUGUST 2013 23:59:59 ',)

    "hh24:mi:ss mon-dd-yyyy")

    GROUP BY user_name,to_char(access_date,'IW')

    );

    PS: He completely untested, but I guess it would help you to get the numbers of the week as well.

  • How can I create legends customized for each image (large) target displayed with the widget to the Gallery?

    Greetings!

    I'm having any joy with the thumbnails Gallery - with the exception of a customization widget, I would like to make.

    I would like to have descriptive legends custom unique each 'target' (large image) image displayed. I can see the legend box personalized, move, modify, etc, but this is fixed for all images in the gallery.

    How do I change each caption for each image of the target?

    Thank you very much

    JL

    Assuming you are talking "Vignettes" under "Slide shows" widget in the widget library, simply drag the widget on a page to insert it. Once inserted, make sure you have legends in reverse by clicking the widget inserted on the page, and then on the small blue arrow top right of the widget that appears once the widget itself is selected, and check the box called "Legends", this will add captions [Lorem Ipsum] to each photo, you can then at this point click or double-click the text "Lorem" on each photo and that you want it to be. I hope this helps.

  • Two Rhcl.exe files (one for each version). How to make the latest version rhcl.exe a recognized command?

    Hi all

    I have two versions installed:

    RoboHELP 9

    RoboHELP 2015

    We are in transition slowly our project in RoboHELP 9. For the moment, I can't uninstall RoboHELP 9, because I still have need for some of my projects.

    The problem that I am running is:

    The RoboHELP command-line compiler, rhcl.exe, is not compile all the subjects.

    Our main help, when I compile it from Magnatune RoboHELP, is usually about 25 MB. When I compile the same help to use the RoboHELP command-line compiler, it's only 4 MB. That's a lot of missing content.

    Here is a smaller output showing the same problem:

    The compilation log shows a bunch of them:

    HHC5003: error:

    Compilation failed when compiling planner\Planner__Introduction.htm.

    I think the problem is with the two versions I installed, it attempts to compile a RoboHELP 2015 project with a compiler of RoboHELP 9.

    I checked that each version has its own rhcl.exe.

    I've renamed the RoboHELP 9 one to "rhcl.exebak" so that it doesn't get used, and now my batch file wrote:
    '' rhcl.exe' is not recognized as an internal or external command.'

    This indicates to me that he was using the RoboHELP 9 compiler.

    How can I get to recognize the rhcl.exe that comes with HR 2015?

    I tried to add my own system pointing to the RH2015 rhcl.exe environment variable, but that does not work either.

    That's what I thought I was doing by adding my own environment variable, but maybe I was doing something wrong.

    In any case, I did a search online, and it says to change the PATH variable.

    In this variable, I added the path to include the folder of the current rhcl.exe.

    Then I rebooted.

    It looks like it could work now. * Phew *.

  • How to add the document level java script to the document via API?

    Hello

    Can someone tell me how to add a document level java script with pdf document?

    Thank you

    Amol

    Here is a link to the JavaScript documentation for the doc.addScript method: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.440.html

  • Do I have to pay extra for each application after you already paid the monthly amount?

    I paid $79.98 for a monthly amount that is said in my mail that it includes all Apps + Adobe Stock. Then when I update an access point (example: indesign) it says start free trial. I then clicked on it and then it gives me an option to buy... do I have to pay an extra $?

    No, the updates and upgrades are included in your monthly subscription.

    Troubleshooting FAQ: What should I do if I have a subscription, but my application acts as if I had a trial?

  • IM connected to an old hard drive and I can't pull the top of all files and the document that are saved on it that I hurt myself?

    problems connecting to seprate hard drive what can I do?

    What exactly happens when you try to retrieve files?

    If you get an "Access denied" message, please see how appropriating a file or a folder in Windows XP , which also applies to Windows Vista and Windows 7.

    Boulder computer Maven
    Most Microsoft Valuable Professional

  • When I add a javascript for printing, it won't run if the document is password

    I created a form field and added javascript to print 'printed' date whenever a document is printed.  It's on, or Web site, and we need to fix (but allow printing).  However, when I set the javascript code is blocked and it prints the date I tested it before getting the file (and not the current date).  Anyone know how to enable javascript when the document is secure?

    Thank you

    Dave

    You must allow the filling of forms.

  • Need of response required for each group of checkboxes before form sends

    Hello world

    I looked at several postings and none of them seem to give me exactly what I need, so now I write to help you please.

    I have a form that contains 25 ranks of issues with groups associated with boxes to answer by the beneficiaries. I need to make a requirement AMONG the boxes are marked for each question before you can submit the form.

    See my screen capture below:

    For example, in the first orange line all 3 boxes are titled ''PAIN'' with the value of exports of: 'YES', 'No.' and 'I don't know'.

    On the second line, all 3 boxes are titled, '1', to export values of: 'YES', 'No.' and 'I don't know'.

    Third row and keep just in the same way. Each line will share the same title and have the value of exports, as mentioned above.

    Is there a script that I can use so that beneficiaries are required to select 1 case in each group/rank until they will be allowed to submit their form?

    Also, if you can provide the script I want to use (if that's the solution), please let me know where you would enter this script (which is - like a mouse point of action, or a paper script, etc.). I'm still learning these steps and need instructions on them.

    If necessary, I use Adobe Acrobat 9 Pro

    Thanks in advance for anyone who can help!

    The script is intended to replace your current order to submit the form.

    To specify multiple recipients you can add them to the cTo parameter, delimited by semicolons, like this:

    } else this.mailDoc ({cTo:"[email protected]; "}) [email protected]; [email protected]'});

  • Error using nested for each activity group transform Oracle SOA 11 g

    I posted this problem in XML general forum section. I don't know if it was in the right place because the error occurs in a BPEL.

    Thank you for taking the time to post this thread.
    I created a XSLT transformation that runs on oxygen, but does not work in a SOA transformation activity.

    Given this XML-

    < country >
    < info enum = "CTRY" name = 'United States' States-total = "50" / >
    < enum = 'ST' index info = '0' sname = "New York" population = "8 244 910" / >
    < enum = 'ST' index info = '0' sname = "Chicago" population = "2 707 120" / >
    < info enum = "CTRY" name = 'Germany' States-total = "16" / >
    < enum = 'ST' index info = '1' sname = population "Berlin" = "3 469 910" / >
    < enum = 'ST' index info = '1' sname = population "Brandenburg" = "2 500 000" / >
    < / country >

    Work of XSLT in the oxygen-

    < xsl: template match = "/" >
    < country >
    [< xsl: for each group-select = "" countries / * ' group-starting-with="info[@enum='CTRY"] ">"
    < CountryInfo >
    < xsl: Call-template name = "ctry" / >
    < / CountryInfo >
    < / xsl: for each group->
    < / country >
    < / xsl: template >

    < xsl: template name = "ctry" >
    < name > country: < xsl: value-of select="@name"/ > < / name >
    districts of <>< xsl: value-of select="@total-states"/ > < / districts >
    < xsl: for each group-select = "current - group ()" group-by="@index" >
    < xsl: Call-template name = "States" / >
    < / xsl: for each group->
    < / xsl: template >

    < xsl: template name = "States" >
    < name of xsl: variable = "index" select="@index"/ >
    States <>
    < xsl: for each select = "current - group ()" >
    < name >
    < xsl: value-of select="@sname"/ >
    < / name >
    < / xsl: foreach >
    < / states >
    < / xsl: template >

    I get the desired oxygen - result

    < country >
    < CountryInfo >
    < name > country: United States of America < / name >
    < > 50 districts < / districts >
    States <>
    < name > New York < / name >
    < name > Chicago < / name >
    < / states >
    < / CountryInfo >
    < CountryInfo >
    < name > country: Germany < / name >
    < > 16 districts < / districts >
    States <>
    < name > Berlin < / name >
    Brandenburg < name > < / name >
    < / states >
    < / CountryInfo >
    < / country >

    In a transformation of Oracle, I get an error "cannot perform XPath expression. I have narrowed down the cause of the error. The error is caused by
    the nested for each group - using 'current - group ()' and 'group-by=@index '.

    < xsl: for each group-select = "current - group ()" group-by="@index" >
    < xsl: Call-template name = "States" / >
    < / xsl: for each group->

    Oracle does not throw an error if I use ' Country/info' instead of ' current - group () or group-starting-with, but this does not produce the desired result.
    because he needs to be grouped by "@index."

    Does anyone know why the Oracle processing activity is not able to use the nested < xsl: for each group-select = "current - group ()" group-by="@index" >?

    This error has been fixed by modifying .

    It seems that the XSLT for Oracle parser does not correctly XSLT 2.0. This is understandable since in 11g does not have full support for XSLT 2.0.

  • Error using nested for each group - in Oracle XSLT

    Hello everyone. Thank you for taking the time to post this thread.
    I created a XSLT transformation that runs on oxygen, but does not work in Oracle.

    Given this XML-

    < country >
    < info enum = "CTRY" name = 'United States' States-total = "50" / >
    < enum = 'ST' index info = '0' sname = "New York" population = "8 244 910" / >
    < enum = 'ST' index info = '0' sname = "Chicago" population = "2 707 120" / >
    < info enum = "CTRY" name = 'Germany' States-total = "16" / >
    < enum = 'ST' index info = '1' sname = population "Berlin" = "3 469 910" / >
    < enum = 'ST' index info = '1' sname = population "Brandenburg" = "2 500 000" / >
    < / country >

    Work of XSLT in the oxygen-

    < xsl: template match = "/" >
    < country >
    [< xsl: for each group-select = "" countries / * ' group-starting-with="info[@enum='CTRY"] ">"
    < CountryInfo >
    < xsl: Call-template name = "ctry" / >
    < / CountryInfo >
    < / xsl: for each group->
    < / country >
    < / xsl: template >

    < xsl: template name = "ctry" >
    < name > country: < xsl: value-of select="@name"/ > < / name >
    districts of <>< xsl: value-of select="@total-states"/ > < / districts >
    < xsl: for each group-select = "current - group ()" group-by="@index" >
    < xsl: Call-template name = "States" / >
    < / xsl: for each group->
    < / xsl: template >

    < xsl: template name = "States" >
    < name of xsl: variable = "index" select="@index"/ >
    States <>
    < xsl: for each select = "current - group ()" >
    < name >
    < xsl: value-of select="@sname"/ >
    < / name >
    < / xsl: foreach >
    < / states >
    < / xsl: template >

    I get the desired oxygen - result

    < country >
    < CountryInfo >
    < name > country: United States of America < / name >
    < > 50 districts < / districts >
    States <>
    < name > New York < / name >
    < name > Chicago < / name >
    < / states >
    < / CountryInfo >
    < CountryInfo >
    < name > country: Germany < / name >
    < > 16 districts < / districts >
    States <>
    < name > Berlin < / name >
    Brandenburg < name > < / name >
    < / states >
    < / CountryInfo >
    < / country >

    In a transformation of Oracle, I get an error "cannot perform XPath expression. I have narrowed down the cause of the error. The error is caused by
    the nested for each group - using 'current - group ().'

    < xsl: for each group-select = "current - group ()" group-by="@index" >
    < xsl: Call-template name = "States" / >
    < / xsl: for each group->

    Oracle does not throw an error if I use ' Country/info' instead of 'current - group ()', but this does not produce the desired result
    because he needs to be grouped by "@index."

    Does anyone know why my XSLT does not work in a transformation from Oracle?

    oracleistheway wrote:
    Does anyone know why my XSLT does not work in a transformation from Oracle?

    What do you mean by "transform Oracle?

    If you are referring to the integrated database XSLT processor available through XMLTransform or DBMS_XSLProcessor API, it does not support XSLT 2.0, 1.0 only.

    If you use the XDK Java (oracle.xml.parser.v2) Please give the exact version.

  • Apply the Navigation option individually for each column... ?

    Hi all
    I posted a question in the morning
    Navigation in a report to another report that I am. But,
    My criteria is that I have columns of detail with image (arrow). The detail contains the details of the failure of a report.

    Let's say, the table is like this with 2 columns

    failed_reason (col1) Retail (col2)
    -----
    SERVER_ERROR image

    NO_DATA_FOUND image


    what I want is that when I click on the image (arrow) its going to hit another report for each reason of failure.
    In the detailed report, we have full reason and solution to overcome this failure
    So is it possible to like this please help me.

    Thank you
    V.saiChAnD

    Hey...

    Seems, must remove '?' in the link you provided...

  • Drag and drop, 1 share of different sur-succes drag Source, 4 Drop target, for each. Is this possible?

    Hello.

    I created an infographic of type board game and wants that the participant to be able to enter the game room, then drop it into different spaces on the Board, each holding to another slide. I need interaction drag - déposer so that they can pick up and drop the piece. Now, what I need is for each target to have a different action, but even if I add each one to a different group, if I change an action for one, that it applies the change to all drop targets.

    Is there a way to get around this?

    In addition, once / if possible, I would like to add a "back button" on each of these slides and would need when the participant returns to the boardgame slide, they can move the piece to a different drop target to read the following description. I think that the best way to do this would be to make all the "wrong" answers, while the game piece is not stuck once they have fell on a drop target "correct." Please correct me if I'm wrong.

    If I understand you correctly, I think that I thought about it.

    1. Create your Drag and Drop, as you would normally
    2. In the Panel of Drag and Drop, select the Options tab
    3. Click on the button set the correct answers
    4. The value of each drop target to have the source of displacement of the source (you must choose the sequence in the Type drop-down list)
    5. Create the slides that you want to display for each drop target
    6. Select one of the drop targets
    7. Go to the Format of the Panel Drag and Drop tab
    8. The Actions of the object... a button click
    9. In the action column, select go to slide, and then select the appropriate slide
    10. Repeat steps 6 through 9 for each target deposit
    11. Overview of the project

    I did a quick test and it seemed to work according to the settings you said earlier.

Maybe you are looking for

  • Satellite A300D-11 q battery problem

    Hello! I was on the point of start almost the same topic, when I saw there was very similar question several hours - [http://forums.computers.toshiba-europe.com/forums/thread.jspa?threadID=61884&tstart=0]. Yet, I decided to share my problem. I have t

  • External microphone realtek Y580 has a lot of comments/quiet

    I have the Y580 and the external microphone is extremely quiet. The works of micro fine on other computers and problems, is that the microphone is very quiet with many comments. If I use any help at all, I get too much feed back. I tried to use the R

  • VI server or reentrant example of Ben?

    A while back, that I can see an example VI post by Ben demonstrating several squares of color separated screw both opens.  They then changed colors randomly (a bit like Christmas lights).  I did some research using the advanced search and can't find

  • Installation of Windows Server 2003 on computers I7

    I would like to know if it is possible to install Windows 2003 Server on unit pre-assembled PC with a core I7 processor. The situation is that we have an old unit of PC which runs under Windows 2003 Server.Our company would like to upgrade the unit f

  • Pavilion p7-1517cb PC and headset problem

    Hello My model is "HP Pavilion p7-1517cb PC" Windows 8.  I plugged my headset communication to green jack of 3.5 mm before (he has beaten symbol underneath).  I can hear the audio, but the microphone is not detected and cannot send my voice (I can't