﻿



// given pathitems, compound path items, and group items,  return list of just the path items.
function collectPathItems(items)
{
    var pathItems = [];
    for(var ix = 0; ix < items.length; ix++)
    {
        var item = items[ix];
        var kind = item.typename;
        
        if(kind == "PathItem")
        {
            pathItems.push(item);
        }
        else if(kind == "CompoundPathItem")
        {
            pathItems = pathItems.concat(citem.pathItems);
        }
        else if(kind == "GroupItem")
        {
            pathItems = pathItems.concat(collectPathItems(item.compoundPathItems));
            pathItems = pathItems.concat(collectPathItems(item.groupItems));
            pathItems = pathItems.concat(citem.pathItems);
        }
    }
    return pathItems;
}
    
	var docRef = documents[0];
	
	var selects = app.selection;
    var s = selects.length + " selected: ";
    for(var ix = 0; ix < selects.length; ix++)
    {
        s += "\n" + selects[ix];
    }
    alert(s);
    
    var pathItems = collectPathItems(selects);
    for(var ix = 0; ix < pathItems.length; ix++)
    {
        var pathItem = pathItems[ix];
        for(px = 0; px < pathItem.pathPoints.length; px++)
        {
            pathPoint = pathItem.pathPoints[px];
            pathPoint.selected = PathPointSelection.ANCHORPOINT;
        }
    }
