Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

Making all paths into a group without selection

$
0
0

I'm working on a script that will take every pathItem in a document and put it into a group (all pathItems in the document are groupless upon opening it, so there won't be other groups already in the document).

 

I have a script that creates a group, then puts the highest placed pathItem into the group. I just can't figure out how to have to grab all pathitems in the document, or loop this one action until everything is in a single group. Also the kicker is, as the title suggests this script has to work without selecting anything by hand first (in other words having to click something to select it). Now if there's was a way to select everything with a script that would be awesome.

 

Here's what I have so far:

 

 

#target Illustrator//based on script from Carlos Canto
var doc = app.activeDocument if ( app.documents.length > 0 ) {
doc = app.activeDocument;
newGroupItem = doc.activeLayer.groupItems.add();} 
var gi = doc.groupItems[0]; // the topmost existing group
var all = doc.pathItems[0]; // all paths in document 
all.move (gi, ElementPlacement.PLACEATBEGINNING); // move selected path inside the group
all.evenodd = true; // necessary to determine "insideness" or to make holes. 

 

I also have this that I found here on the forum

 

#target Illustrator// GroupFromSel.jsx// regards pixxxelschubser if ( app.documents.length > 0 && app.activeDocument.selection.length > 0) {    var aDoc = app.activeDocument;    var Sel = aDoc.selection;    var GroupFromSel = aDoc.groupItems.add();    for ( i = Sel.length-1; i >= 0; i--) {        Sel[i].moveToBeginning( GroupFromSel )        }} 

 

But saddly it requires selecting so two scripts, two possible solutions. I'm just working on both until I can get one to work.

 

Any ideas?


Viewing all articles
Browse latest Browse all 12845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>